<!-- Javascript function to check the submitted form has been filled in correctly before submitting -->

<!-- Hide from older browsers
	
//Check the enquiry form is filled in correctly
function CheckForm () { 

	//Initialise variables
	var errorMsg = "";

//Funtion to check that Quantity is a number	
	 function IsNumeric(sText)
{
   var ValidChars = "0123456789.";
   var IsNumber=true;
   var Char;

   for (i = 0; i < sText.length && IsNumber == true; i++) 
      { 
      Char = sText.charAt(i); 
      if (ValidChars.indexOf(Char) == -1) 
         {
         IsNumber = false;
         }
      }
   return IsNumber;
   
   } 

	//Check for a first name
	if (document.formConveyancing.Name_first.value == ""){
		errorMsg += "\n\tFirst Name \t- Enter your First Name";	
	}
	
	//Check for a last name
	if (document.formConveyancing.Name_last.value == ""){
		errorMsg += "\n\tLast Name \t- Enter your Surname";
	}
	
	 	
	//Check for an e-mail address and that it is valid
	if ((document.formConveyancing.email.value == "") || (document.formConveyancing.email.value.length > 0 && (document.formConveyancing.email.value.indexOf("@",0) == - 1 || document.formConveyancing.email.value.indexOf(".",0) == - 1))) { 
		errorMsg += "\n\tE-mail Address \t- Enter your valid e-mail address";
	}
		//Check for Tel Number
	if ((document.formConveyancing.tel_day.value == "") && (document.formConveyancing.tel_evening.value == ""))
	{
		errorMsg += "\n\tTelephone Number\t-  Enter day or evening Telephone numerical value";
	}
		 	//Check Day Tel Number is numerical only
	if (!IsNumeric(document.formConveyancing.tel_day.value)){
		errorMsg += "\n\tDay Telephone Number\t- Numerical value only (No spaces)";
	}
		 	//Check Evening Tel Number is numerical only
	if (!IsNumeric(document.formConveyancing.tel_evening.value)){
		errorMsg += "\n\tEvening Telephone Number\t- Numerical value only (No spaces)";
	}	
	
		//Check for a company name
	if (document.formConveyancing.company.value == ""){
		errorMsg += "\n\tCompany \t- Enter your company name";
	}
	
//				 	//Check Fax Number is numerical only
//	if (!IsNumeric(document.formConveyancing.fax.value)){
//		errorMsg += "\n\tFax Number\t- Numerical value only";
	//}

	//Check for an address
//	if (document.formConveyancing.address.value == ""){
//		errorMsg += "\n\tAddress \t- Enter your Address";
//	}
		
	//If there is aproblem with the form then display an error
	if (errorMsg != ""){
		msg = "______________________________________________________________\n\n";
		msg += "Thank you for your information, unfortunately some of the data has not been entered correctly\n";
		msg += "Please correct the problem(s) and re-submit the form.\n";
		msg += "______________________________________________________________\n\n";
		msg += "The following field(s) need to be corrected: -\n";
		
		errorMsg += alert(msg + errorMsg + "\n\n");
		return false;
	}
	
	return true;
}
// -->


