
function isEmail(string) {

if (string.search(/^\w+((-\w+)|(\.\w+))*\@\w+((\.|-)\w+)*\.\w+$/) != -1)
return 1;
else
return 0;
}


function CheckForm(form){

if ( form.email.value=="") {
   	alert("Please, fill the email field!");
    	return false; 	
}

else {
                
if ( isEmail(form.email.value) == 0 ) {
alert("Invalid email address");
return false;

}	
}

if ( form.nome.value=="") {
   	alert("Please, fill the username field!");
    	return false; 	
}

else {

if (form.nome.value.length<4) {
   	alert("Username is too short");
    	return false; 	
}
else if (form.nome.value.length>18){
   	alert("Username is too long");
    	return false; 
}

}


if ( form.pass.value=="") {
   	alert("Please, fill the password field!");
    	return false; 	
}

else {

if (form.pass.value.length<4) {
   	alert("Password is too short");
    	return false; 	
}
else if (form.pass.value.length>18){
   	alert("Password is too long");
    	return false; 
}

}

if (form.pass.value != form.conferma.value) {
   	alert("Please, type properly the confirmation password field!");
    	return false; 	
}



if ( form.code.value=="") {
   	alert("Please, fill the antispam code field!");
    	return false; 	
}

else {
                
if (form.code.value.length!=6) {
   	alert("Please, fill properly the antispam code field!");
    	return false; 	
}

}



}