// CONTROLLO CAMPI FORM PERSONALIZZATO
// (C) Alessio Gattei - gattei.com
// 
   function check_registrazione()
   {
   if (!document.registrazione.privacy.checked)
	{
		window.alert ("E' necessario acconsentire al trattamento dei dati personali");
		return false;
	}
// Controllo Nome
   var name=document.registrazione.name.value;
   if (name=="")
	{
        window.alert ("Il campo NAME deve essere compilato !");
		return false;
	}
   if (name.length<2 || name.length>30)
	{
        window.alert ("Il campo NAME deve essere di min. 2 e max. 30 caratteri !");
		return false;
	}
// Controllo Cognome
   var surname=document.registrazione.surname.value;
   if (surname=="")
	{
        window.alert ("Il campo SURNAME deve essere compilato !");
        return false;
	}
   if (surname.length<2 || surname.length>30)
	{
        window.alert ("Il campo SURNAME deve essere di min. 2 e max. 30 caratteri !");
		return false;
	}
// Controllo Email
   var email=document.registrazione.email.value;
   var flag_at,flag_dot;
   if (email=="")
	{
        window.alert ("Il campo E-MAIL deve essere compilato !");
		return false;
	}
   if (email.length<7 || email.length>50)
	{
        window.alert ("Il campo E-MAIL non è valido !");
		return false;
	}
   flag_at=false;
   flag_dot=false;
   for (var j=0;j<51;j++)
	{
        if (email.charAt(j)=="@")
		{
		flag_at=true;
		}
        if (email.charAt(j)==".")
		{
		flag_dot=true;
                }
        }
   if (flag_at==false || flag_dot==false)
	{
        window.alert ("Il campo E-MAIL deve contenere i caratteri @ e .");
		return false;
	}
   document.registrazione.email.value=email.toLowerCase();
// Controllo How did you find out about us?
   var how=document.registrazione.how.value;
   if (how=="")
	{
        window.alert ("Il campo 'How did you find out about us?' deve essere compilato !");
		return false;
	}

// fine controlli
return true;
}
