function Form1_Validator(theForm)
{

  if (theForm.Arrivo.value == "")
  {
    alert("Please insert a value for the \"Check-in\" field");
    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("Pay attention: the correct value for the \"Check-in\" field should be in \"dd/mm/yyyy\"");
           theForm.Arrivo.select();
              return (false);
        }
    
      if (theForm.Arrivo.value.length!==10)
    {
     alert ("Pay attention: the correct value for the \"Check-in\" field should be in \"dd/mm/yyyy\"");
     theForm.Arrivo.focus();
     return (false);
    } 
    
           else if (theForm.Arrivo.value.substring(0,2) > 31) {
           alert("Pay attention: You can't use in the field \"Check-in\" a value exceeding 31 per day");
           theForm.Arrivo.select();
           return (false);
        }


           else if (theForm.Arrivo.value.substring(0,2) == "00") {
           alert("Pay attention: You can't use in the field \"Check-in\" a value of less than 01 for the day");
           theForm.Arrivo.select();
           return (false);
        }


         else if (theForm.Arrivo.value.substring(3,5) > 12) {
           alert("Pay attention: You can't use in the field \"Check-in\" a value exceeding 12 per month");
           theForm.Arrivo.select();
           return (false);
        }


         else if (theForm.Arrivo.value.substring(3,5) == "00") {
           alert("Pay attention: You can't use in the field \"Check-in\" a value of less than 01 month");
           theForm.Arrivo.select();
           return (false);
        }



         else if (theForm.Arrivo.value.substring(6,10) < 1900) {
           alert("Pay attention: You can't use in the field \"Check-in\" a value of less than 1900 for the year");
           theForm.Arrivo.select();
           return (false);
        }  
       
  
    if (theForm.Partenza.value == "")
  {
    alert("Please insert a value for the \"Check-out\" field");
    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("Pay attention: the correct value for the \"Check-out\" field should be in \"dd/mm/yyyy\"");
           theForm.Partenza.select();
              return (false);
        }
    
      if (theForm.Partenza.value.length!==10)
    {
     alert ("Pay attention: the correct value for the \"Check-out\" field should be in \"dd/mm/yyyy\"");
     theForm.Partenza.focus();
     return (false);
    } 
    
           else if (theForm.Partenza.value.substring(0,2) > 31) {
           alert("Pay attention: You can't use in the field \"Check-out\" a value exceeding 31 per day");
           theForm.Partenza.select();
           return (false);
        }


           else if (theForm.Partenza.value.substring(0,2) == "00") {
           alert("Pay attention: You can't use in the field \"Check-out\" a value of less than 01 for the day");
           theForm.Partenza.select();
           return (false);
        }


         else if (theForm.Partenza.value.substring(3,5) > 12) {
           alert("Pay attention: You can't use in the field \"Check-out\" a value exceeding 12 per month");
           theForm.Partenza.select();
           return (false);
        }


         else if (theForm.Partenza.value.substring(3,5) == "00") {
           alert("Pay attention: You can't use in the field \"Check-out\" a value of less than 01 month");
           theForm.Partenza.select();
           return (false);
        }


         else if (theForm.Partenza.value.substring(6,10) < 1900) {
           alert("Pay attention: You can't use in the field \"Check-out\" a value of less than 1900 for the year");
           theForm.Partenza.select();
           return (false);
        }  

 
    if (theForm.Notti.value == "0")
  {
    alert("Please insert a value for the \"Nights\" field");
    theForm.Notti.focus();
    return (false);
  }
  
  
      if (theForm.TipCamera.value == "0")
  {
    alert("Please insert a value for the \"Rooms type\" field");
    theForm.TipCamera.focus();
    return (false);
  }
  
  
        if (theForm.Sistemazione.value == "0")
  {
    alert("Please insert a value for the \"Accomodation\" field");
    theForm.Sistemazione.focus();
    return (false);
  }
  
  
      if (theForm.Adulti.value == "0")
  {
    alert("Please insert a value fot the \"Adult\" field");
    theForm.Adulti.focus();
    return (false);
  }
  
  if (theForm.Cognome.value == "")
  {
    alert("Please insert a value fot the \"Surname\" field");
    theForm.Cognome.focus();
    return (false);
  }
  
  var re_not_all = /^([a-zA-Z\. '])+$/;

if (!re_not_all.test(theForm.Cognome.value)) {
	alert("Pay attention: The field \"Surname\" can only contain text");
	theForm.Cognome.focus();
	return (false);
}
  
  
  if (theForm.Nome.value == "")
  {
    alert("Please insert a value for the \"Name\" field");
    theForm.Nome.focus();
    return (false);
  }
  
  
    var re_not_all = /^([a-zA-Z\. '])+$/;

if (!re_not_all.test(theForm.Nome.value)) {
	alert("Pay attention: The field \"Name\" can only contain text");
	theForm.Nome.focus();
	return (false);
}
  
  
    if (theForm.Nazione.value == "")
  {
    alert("Please insert a value for the \"Country\" field");
    theForm.Nazione.focus();
    return (false);
  }
  
  
      var re_not_all = /^([a-zA-Z\. '])+$/;

if (!re_not_all.test(theForm.Nazione.value)) {
	alert("Pay attention: The field \"Country\" can only contain text");
	theForm.Nazione.focus();
	return (false);
}
  
  
     if (theForm.Email.value == "")
  {
    alert("Please insert a value for the \"E-mail\" field");
    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("Pay attention: The field \"E-mail\" is not valid");
	return stato;
	}
	
	
	    if (theForm.securitycode.value == "")
  {
    alert("Please insert a value for the \"Security Code\" field");
    theForm.securitycode.focus();
    return (false);
  }
  
  if (theForm.check.checked == "0")
  {
    alert("Pay attention: Youn need to confirm that you have read and allow the law about Personal Data");
    theForm.check.focus();
    return (false);
  }

  return (true);
}





