

function validaModulo(nomeModulo)
{

  if(nomeModulo.azienda.value==""){
  	alert("Il campo azienda è obbligatorio");
  	nomeModulo.azienda.focus();
  	return false;
  }

  if(nomeModulo.nome.value==""){
  	alert("Il campo nome è obbligatorio");
  	nomeModulo.nome.focus();
  	return false;
  }
  
  if(nomeModulo.cognome.value==""){
  	alert("Il campo cognome è obbligatorio");
  	nomeModulo.cognome.focus();
  	return false;
  }

//  if(nomeModulo.telefono.value==""){
//  	alert("Il campo telefono è obbligatorio");
//  	nomeModulo.telefono.focus();
//  	return false;
//  }

  
  if(nomeModulo.mail.value==""){
  	alert("Il campo email è obbligatorio");
  	nomeModulo.mail.focus();
  	return false;
  }
  
	if (nomeModulo.mail.value!=""){
		checkEmailAddress(nomeModulo.mail)
		if (good == false)
			{
			return false
			}   
	 }

//  if(nomeModulo.indirizzo.value==""){
//  	alert("Il campo indirizzo è obbligatorio");
//  	nomeModulo.indirizzo.focus();
//  	return false;
//  }
//
//  if(nomeModulo.cap.value==""){
//  	alert("Il campo cap è obbligatorio");
//  	nomeModulo.cap.focus();
//  	return false;
//  }
  
//  if(nomeModulo.piva.value=="")
//  {
//  	alert("Il campo partita iva è obbligatorio");
//  	nomeModulo.piva.focus();
//  	return false;
//  }
//
  if(nomeModulo.citta.value=="")
  {
  	alert("Il campo citta è obbligatorio");
  	nomeModulo.citta.focus();
  	return false;
  }

  if(nomeModulo.check[1].checked)
  {
    alert("Non è stato dato il consenso per il trattamento dei dati personali");
    
    nomeModulo.check[0].focus();
    return false;
  }

    var el=document.getElementById('Sub');
	el.style.display="none";

}


function verifica_numero(campo,event){
var tasto, carattereTasto;
if(window.event)
tasto=window.event.keyCode;
else if(event)
tasto=event.which;
else return true;

carattereTasto=String.fromCharCode(tasto);

if((tasto==null)||(tasto==0)||(tasto==8)||(tasto==9)||(tasto==13)||(tasto==27))
return true;
else if ((("0123456789").indexOf(carattereTasto) > -1))
{
window.status="";
return true;
}
else
{
window.status="il campo accetta solo numeri";
return false;
}
}

//evita che nel campo vengano inseriti dei numeri
function non_numeri(campo,event){
var tasto, carattereTasto;
if(window.event)
tasto=window.event.keyCode;
else if(event)
tasto=event.which;
else return true;

carattereTasto=String.fromCharCode(tasto);

if((tasto==null)||(tasto==0)||(tasto==8)||(tasto==9)||(tasto==13)||(tasto==27))
return true;
else if ((("asdfghjklpoiuytrewqzxcvbnmQWETYUIOPASDFGHJKLZXCVBNMRàèìòù ").indexOf(carattereTasto) > -1))
{
window.status="";
return true;
}
else
{
window.status="il campo accetta solo lettere";
return false;
}
}

function checkEmailAddress(field) {

var goodEmail = field.value.match(/\b(^(\S+@).+((\.com)|(\.net)|(\.edu)|(\.mil)|(\.gov)|(\.org)|(\..{2,2}))$)\b/gi);

if (goodEmail){
   good = true
} else {
   alert('Inserisci un indirizzo email valido.')
   field.focus()
   field.select()
   good = false
   }
}



