function Form1_Validator(theForm)
{

  if (theForm.Arrivo.value == "")
  {
    alert("Attenzione: Il campo \"Check-in\" è obbligatorio");
    theForm.Arrivo.focus();
    return (false);
  }
    
      
    if (theForm.Arrivo.value.substring(2,3) != "/" ||
           theForm.Arrivo.value.substring(5,6) != "/" ||
           isNaN(theForm.Arrivo.value.substring(0,2)) ||
           isNaN(theForm.Arrivo.value.substring(3,5)) ||
           isNaN(theForm.Arrivo.value.substring(6,10))) {
             alert("Attenzione: La data nel campo \"Check-in\" deve essere in formato \"gg/mm/aaaa\"");
           theForm.Arrivo.select();
              return (false);
        }
    
      if (theForm.Arrivo.value.length!==10)
    {
     alert ("Attenzione: La data nel campo \"Check-in\" deve essere in formato \"gg/mm/aaaa\"");
     theForm.Arrivo.focus();
     return (false);
    } 
    
           else if (theForm.Arrivo.value.substring(0,2) > 31) {
           alert("Attenzione: Impossibile utilizzare nel campo \"Check-in\" un valore superiore a 31 per i giorni");
           theForm.Arrivo.select();
           return (false);
        }


           else if (theForm.Arrivo.value.substring(0,2) == "00") {
           alert("Attenzione: Impossibile utilizzare nel campo \"Check-in\" un valore inferiore a 01 per i giorni");
           theForm.Arrivo.select();
           return (false);
        }


         else if (theForm.Arrivo.value.substring(3,5) > 12) {
           alert("Attenzione: Impossibile utilizzare nel campo \"Check-in\" un valore superiore a 12 per i mesi");
           theForm.Arrivo.select();
           return (false);
        }


         else if (theForm.Arrivo.value.substring(3,5) == "00") {
           alert("Attenzione: Impossibile utilizzare nel campo \"Check-in\" un valore inferiore a 01 per i mesi");
           theForm.Arrivo.select();
           return (false);
        }



         else if (theForm.Arrivo.value.substring(6,10) < 1900) {
           alert("Attenzione: Impossibile utilizzare nel campo \"Check-in\" un valore inferiore a 1900 per l'anno");
           theForm.Arrivo.select();
           return (false);
        }  
       
  
    if (theForm.Partenza.value == "")
  {
    alert("Attenzione: Il campo \"Check-out\" è obbligatorio");
    theForm.Partenza.focus();
    return (false);
  }
  
  
   if (theForm.Partenza.value.substring(2,3) != "/" ||
           theForm.Partenza.value.substring(5,6) != "/" ||
           isNaN(theForm.Partenza.value.substring(0,2)) ||
           isNaN(theForm.Partenza.value.substring(3,5)) ||
           isNaN(theForm.Partenza.value.substring(6,10))) {
             alert("Attenzione: La data nel campo \"Check-out\" deve essere in formato \"gg/mm/aaaa\"");
           theForm.Partenza.select();
              return (false);
        }
    
      if (theForm.Partenza.value.length!==10)
    {
     alert ("Attenzione: La data nel campo \"Check-out\" deve essere in formato \"gg/mm/aaaa\"");
     theForm.Partenza.focus();
     return (false);
    } 
    
           else if (theForm.Partenza.value.substring(0,2) > 31) {
           alert("Attenzione: Impossibile utilizzare nel campo \"Check-out\" un valore superiore a 31 per i giorni");
           theForm.Partenza.select();
           return (false);
        }


           else if (theForm.Partenza.value.substring(0,2) == "00") {
           alert("Attenzione: Impossibile utilizzare nel campo \"Check-out\" un valore inferiore a 01 per i giorni");
           theForm.Partenza.select();
           return (false);
        }


         else if (theForm.Partenza.value.substring(3,5) > 12) {
           alert("Attenzione: Impossibile utilizzare nel campo \"Check-out\" un valore superiore a 12 per i mesi");
           theForm.Partenza.select();
           return (false);
        }


         else if (theForm.Partenza.value.substring(3,5) == "00") {
           alert("Attenzione: Impossibile utilizzare nel campo \"Check-out\" un valore inferiore a 01 per i mesi");
           theForm.Partenza.select();
           return (false);
        }


         else if (theForm.Partenza.value.substring(6,10) < 1900) {
           alert("Attenzione: Impossibile utilizzare nel campo \"Check-out\" un valore inferiore a 1900 per l'anno");
           theForm.Partenza.select();
           return (false);
        }  

 
    if (theForm.Notti.value == "0")
  {
    alert("Attenzione: Il campo \"Notti\" è obbligatorio");
    theForm.Notti.focus();
    return (false);
  }
  
  
      if (theForm.TipCamera.value == "0")
  {
    alert("Attenzione: Il campo \"Tipologia Camera\" è obbligatorio");
    theForm.TipCamera.focus();
    return (false);
  }
  
  
        if (theForm.Sistemazione.value == "0")
  {
    alert("Attenzione: Il campo \"Sistemazione\" è obbligatorio");
    theForm.Sistemazione.focus();
    return (false);
  }
  
  
      if (theForm.Adulti.value == "0")
  {
    alert("Attenzione: Il campo \"Adulti\" è obbligatorio");
    theForm.Adulti.focus();
    return (false);
  }
  
  if (theForm.Cognome.value == "")
  {
    alert("Attenzione: Il campo \"Cognome\" è obbligatorio");
    theForm.Cognome.focus();
    return (false);
  }
  
  var re_not_all = /^([a-zA-Z\. '])+$/;

if (!re_not_all.test(theForm.Cognome.value)) {
	alert("Attenzione: Il campo \"Cognome\" può contenere solo testo");
	theForm.Cognome.focus();
	return (false);
}
  
  
  if (theForm.Nome.value == "")
  {
    alert("Attenzione: Il campo \"Nome\" è obbligatorio");
    theForm.Nome.focus();
    return (false);
  }
  
  
    var re_not_all = /^([a-zA-Z\. '])+$/;

if (!re_not_all.test(theForm.Nome.value)) {
	alert("Attenzione: Il campo \"Nome\" può contenere solo testo");
	theForm.Nome.focus();
	return (false);
}
  
  
    if (theForm.Nazione.value == "")
  {
    alert("Attenzione: Il campo \"Nazione\" è obbligatorio");
    theForm.Nazione.focus();
    return (false);
  }
  
  
      var re_not_all = /^([a-zA-Z\. '])+$/;

if (!re_not_all.test(theForm.Nazione.value)) {
	alert("Attenzione: Il campo \"Nazione\" può contenere solo testo");
	theForm.Nazione.focus();
	return (false);
}
  
  
     if (theForm.Email.value == "")
  {
    alert("Attenzione: il campo \"E-mail\" è obbligatorio");
    theForm.Email.focus();
    return (false);
  }

	var stato=true;
	if(theForm.Email.value.indexOf(" ")!=-1) {
	theForm.Email.focus();
	stato=false;
	}
	var chiocciola=theForm.Email.value.indexOf("@");
	if(chiocciola<2) {
	theForm.Email.focus();
	stato=false;
	}
	var punto=theForm.Email.value.indexOf(".", chiocciola);
	if(punto<chiocciola+3) {
	theForm.Email.focus();
	stato=false;
	}
	var lung=theForm.Email.value.length;
	if(lung-punto<3) {
	theForm.Email.focus();
	stato=false;
	}

	if(stato==false) {
		alert("Attenzione: il campo \"E-mail\" non è valido");
	return stato;
	}
	
	
	    if (theForm.securitycode.value == "")
  {
    alert("Attenzione: il campo \"Codice di sicurezza\" è obbligatorio");
    theForm.securitycode.focus();
    return (false);
  }
  
  if (theForm.check.checked == "0")
  {
    alert("Attenzione: E' necessario confermare di aver letto le note sul trattamento dei Dati Personali");
    theForm.check.focus();
    return (false);
  }

  return (true);
}






