function check() {
var stato = true;
		//CAMPI OBBLIGATORI COPIARE QUESTE RIGHE
	
	if ((stato == true)&&(document.theform.nome.value == "")) {
		testo = "Campo nome obbligatorio";
		stato = false; 
		theform.nome.focus();    
	}
	
	if ((stato == true)&&(document.theform.cognome.value == "")) {
		testo = "Campo cognome obbligatorio";
		stato = false; 
		theform.cognome.focus();    
	}
	
	if ((stato == true)&&(document.theform.carica_cliente.value == "")) {
		testo = "Campo carica obbligatorio";
		stato = false; 
		theform.carica_cliente.focus();    
	}
	
	if ((stato == true)&&(document.theform.azienda.value == "")) {
		testo = "Campo azienda obbligatorio";
		stato = false; 
		theform.azienda.focus();    
	}
	
	if ((stato == true)&&(document.theform.indirizzo.value == "")) {
		testo = "Campo indirizzo obbligatorio";
		stato = false; 
		theform.indirizzo.focus();    
	}
	
	if ((stato == true)&&(document.theform.cap.value == "")) {
		testo = "Campo cap obbligatorio";
		stato = false; 
		theform.cap.focus();    
	}
//CONTROLLO CARATTERI VALIDI NEL CAP
	var valida = "0123456789"; 	
		//aggiunggere il . o la ,
    var ok = "yes";
    var temp;

	for (var i=0; i<document.theform.cap.value.length; i++) {
               temp = "" + document.theform.cap.value.substring(i, i+1);
               if (valida.indexOf(temp) == "-1") ok = "no";
       }
               
      if (ok == "no") {
           testo = "Carattere non valido nel campo cap, è possibile inserire solo numeri";
            document.theform.cap.focus();     
			stato = false;
       }	
	
	
	
	if ((stato == true)&&(document.theform.provincia.value == "")) {
		testo = "Campo provincia obbligatorio";
		stato = false; 
		theform.provincia.focus();    
	}
	
	if ((stato == true)&&(document.theform.localita.value == "")) {
		testo = "Campo località obbligatorio";
		stato = false; 
		theform.localita.focus();    
	}
	
	if ((stato == true)&&(document.theform.partita_iva.value == "")) {
		testo = "Campo partita iva obbligatorio";
		stato = false; 
		theform.partita_iva.focus();    
	}
	
	if ((stato == true)&&(document.theform.telefono.value == "")) {
		testo = "Campo telefono obbligatorio";
		stato = false; 
		theform.telefono.focus();    
	}
	
	if ((stato == true)&&(document.theform.fax.value == "")) {
		testo = "Campo fax obbligatorio";
		stato = false; 
		theform.fax.focus();    
	}
	
	if ((stato == true)&&(document.theform.email.value == "")) {
		testo = "Campo e-mail obbligatorio";
		stato = false; 
		theform.email.focus();    
	}
	
//privacy	
	if ((stato == true)&&(document.theform.privacy[1].checked)) {
		testo = "Per proseguire e' necessario\nacconsentire al trattamento dei dati\n(consenso privacy).";
		stato = false;     
	}
//privacy / fine



	//VALIDAZIONE E-MAIL
	if (theform.email.value!="")	{
		if ((theform.email.value.length<6)&&(stato==true)) {
			testo = "L'email inserita e' troppo corta.\n";
			stato = false;
			theform.email.focus();    	
		}
		if ((theform.email.value.indexOf('.')==-1)&&(stato==true)) {
			testo = "L'email inserita non e' valida.\n(es: nome@nomeweb.com)";
			stato = false;
			theform.email.focus();    	
		}
		if ((theform.email.value.indexOf('@')==-1)&&(stato==true)) {
			testo = "L'email inserita non e' valida.\n(es: nome@nomeweb.com)";
			stato = false;
			theform.email.focus();    	
		}
		if ((theform.email.value.indexOf('@')!=theform.email.value.lastIndexOf('@'))&&(stato==true)) {
			testo = "L'email inserita non e' valida.\n(es: nome@nomeweb.com)";
			stato = false;
			theform.email.focus();    	
		}
		if ((theform.email.value.indexOf(':')!=-1)&&(stato==true)) {
			testo = "L'email inserita non e' valida.\n(es: nome@nomeweb.com)";
			stato = false;
			theform.email.focus();    	
		}
		if ((theform.email.value.indexOf(' ')!=-1)&&(stato==true)) {
			testo = "L'email inserita non e' valida.\nNon utilizzare spazi.\n(es: nome@nomeweb.com)";
			stato = false;
			theform.email.focus();    	
		} 
	}
	
	
		
	if (stato == false){
		alert(" "+testo+" ")	}
		
		
		
return (stato)
}

