

function validaModulo(nomeModulo)
{
  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.email.value==""){
  	alert("Il campo email è obbligatorio");
  	nomeModulo.email.focus();
  	return false;
  }
  
	if (nomeModulo.email.value!=""){
		checkEmailAddress(nomeModulo.email)
		if (good == false)
			{
			return false
			}   
	 }

  if(nomeModulo.indirizzo.value==""){
  	alert("Il campo indirizzo è obbligatorio");
  	nomeModulo.indirizzo.focus();
  	return false;
  }
  
  if(nomeModulo.citta.value=="")
  {
  	alert("Il campo città è obbligatorio");
  	
  	nomeModulo.citta.focus();
  	return false;
  }
  
  if(nomeModulo.telefono.value=="")
  {
  	alert("Il campo telefono è obbligatorio");
  	
  	nomeModulo.telefono.focus();
  	return false;
  }
  
  if(nomeModulo.trattamento_dati_personali[1].checked)
  {
    alert("Non è stato dato il consenso per la comunicazione e trattamento dei dati personali");
    
    nomeModulo.trattamento_dati_personali[0].focus();
    return false;
  }
}


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
   }
}


