function valida2(form)
{
    var i;
	var trovato=0;


//CONTROLLI PER IL CAMPO NOME
   if (document.modulo2.nome.value.length == 0)
    {
		alert("Il campo NOME e COGNOME é obbligatorio!");
		document.modulo2.nome.focus();
		return false;
	}
//FINE CONTROLLI PER IL CAMPO NOME

   if (document.modulo2.telefono.value.length == 0)
    {
     alert("Il campo TELEFONO è obbligatorio!");
     document.modulo2.telefono.focus();
     return false;
    }  
    if(isNaN(document.modulo2.telefono.value))
    {
      alert("Non inserite spazi bianchi nel TELEFONO");
      document.modulo2.telefono.focus();
      return false;
    }


//CONTROLLI PER IL CAMPO EMAIL
            
  var e_mail;
  e_mail=document.modulo2.mail.value;
  
  
    /* if (document.modulo2.mail.value.length == 0) {
		alert("Il campo E-MAIL é obbligatorio.");
		document.modulo2.mail.focus();
		return false;
	}  */

if (document.modulo2.mail.value.length > 0)
{
	
	for(i=0;i<document.modulo2.mail.value.length;i++)
	{
		if(document.modulo2.mail.value.lastIndexOf("@")<1)
		{
		alert("il carattere @ [chiocciola] deve essere presente nel campo E-MAIL");
		document.modulo2.mail.focus();
		return false;
		}
	}

if (document.modulo2.mail.value.substring(0).charCodeAt()==45||document.modulo2.mail.value.substring(0).charCodeAt()==46||document.modulo2.mail.value.substring(0).charCodeAt()==64||document.modulo2.mail.value.substring(0).charCodeAt()==95) {
		alert("Il PRIMO carattere del campo E-MAIL non può essere nessuno dei seguenti caratteri:\npunto [.], chiocciola [@], trattino [-], underscore [_].");
		document.modulo2.mail.focus();
		return false;
		}
		
		for(i=0;i<document.modulo2.mail.value.length;i++)  //visualizza l' alert se nel campo sono presenti caratteri non consentiti
		{
        if(document.modulo2.mail.value.charCodeAt(i)!=32&&document.modulo2.mail.value.charCodeAt(i)!=45&&document.modulo2.mail.value.charCodeAt(i)!=46&&document.modulo2.mail.value.charCodeAt(i)<48||document.modulo2.mail.value.charCodeAt(i)>57&&document.modulo2.mail.value.charCodeAt(i)< 64|| document.modulo2.mail.value.charCodeAt(i)>90 && document.modulo2.mail.value.charCodeAt(i)!=95&&document.modulo2.mail.value.charCodeAt(i)<97|| document.modulo2.mail.value.charCodeAt(i)>122)
	      {
        alert("Nel campo E-MAIL il carattere ["+document.modulo2.mail.value.substring(i,i+1)+"] non è consentito");
         document.modulo2.mail.focus();
	return false;
	 }
	}
	
     for(i=0;i<document.modulo2.mail.value.length;i++)  //visualizza l' alert se nel campo è presente il carattere (spazio)
	{
        if(document.modulo2.mail.value.charCodeAt(i)==32)
        {
        alert("Il carattere [spazio] nel campo E-MAIL non è consentito");
         document.modulo2.mail.focus();
         return false;
	 }
         }
   
   
  
         	
var chiocciolaCount = 0;
var foundatposition = 0;
while(foundatposition != -1)  {
	foundatposition = e_mail.indexOf("@", foundatposition);
	if (foundatposition != -1) {
		chiocciolaCount++;
		foundatposition++;
	}
	}
	
	if (chiocciolaCount>1) {
	alert("Attenzione! Hai inserito " + chiocciolaCount + " volte il simbolo [@]. Negli indirizzi e-mail ne puoi inserire solamente uno!");
	document.modulo2.mail.focus();
	return false;
	}


var filter = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
if (!filter.test(document.modulo2.mail.value)) {
alert('Prego verificare l\'estensione della email');
document.modulo2.mail.focus();
return false;
}

	
 	if (e_mail.lastIndexOf("@.") > 0 || e_mail.lastIndexOf(".@") > 0) {
		alert("Nel campo E-MAIL c'é un errore!\nI caratteri [@] e [.] non sono consentiti consecutivamente");
		document.modulo2.mail.focus();
		return false;
	}
 		
	
	if (e_mail.lastIndexOf("..") > 0) {
		alert("Nel campo E-MAIL non sono ammessi i punti [..] consecutivi.");
		document.modulo2.mail.focus();
		return false;
		}


//FINE CONTROLLI EMAIL
}




//CONTROLLI PER IL CV
   if (document.modulo2.messaggio.value.length == 0)
    {
		alert("Il campo MESSAGGIO é obbligatorio!");
		document.modulo2.messaggio.focus();
		return false;
	}
//FINE CONTROLLI PER IL CV

//CONTROLLI TELEFONO
   if (document.modulo2.code.value.length == 0)
    {
     alert("Il campo CODICE ANTISPAM è obbligatorio!");
     document.modulo2.code.focus();
     return false;
    }  

//FINE CONTROLLI TELEFONO

//CONTROLLI PER LA PRIVACY
   if(document.modulo2.privacy.checked == false)
   {
     alert("Autorizzare il trattamento dei dati personali.");
     document.modulo2.privacy.focus();
     return false; 
   }  
//FINE CONTROLLI PRIVACY

return true;
}	