

<!-- FORM VALIDATION -->

/************************************************
 bool ValidateEmail(string input)
 Return true or false
 if the email is valid or not.
 checks for @ and .
**************************************************/
function ValidateEmail(theinput){
 var s=theinput;
 if(s.search)
  return (s.search(new RegExp("^([-!#$%&'*+./0-9=?A-Z^_`a-z{|}~])+@([-!#$%&'*+/0-9=?A-Z^_`a-z{|}~]+\\.)+[a-zA-Z]{2,4}$","gi"))>=0);
 if(s.indexOf)
 {
  at_character=s.indexOf('@');
  if(at_character<=0 || at_character+4>s.length)
   return false;
 }
 if(s.length<6)
  return false;
 else
  return true;
}
 
/************************************************
 bool ValidateName(string input)
 Return true or false
 if the email is valid or not.
**************************************************/
function ValidateName(theinput){
 var s=theinput;
 if(s.search)
  return (s.search(new RegExp("^[^&'^`]+$","gi"))>=0);
 if(s.length<3)
  return false;
 else
  return true;
}
 
/************************************************
 bool ValidatePhone(string input)
 Return true or false
 if the phone number is valid or not.
 acepts - and + symbols
**************************************************/
function ValidatePhone(theinput){
 var s=theinput;
 if(s.search)
  return (s.search(new RegExp("[-+0-9]+","gi"))>=0);
 if(s.length<5)
  return false;
 else
  return true;
}
 

function CheckContactusForm(){
	var error="";

	if(!ValidateName(document.frmContactus.fname.value))
		error+="First Name\n";
	
	if(!ValidateName(document.frmContactus.lname.value))
		error+="Last Name\n";

	if(!ValidateEmail(document.frmContactus.email.value))
		error+="Email\n";
	
	if(document.frmContactus.address1.value=="")
		error+="Address 1\n";

	if(document.frmContactus.city.value=="")
		error+="City\n";

	if(document.frmContactus.state.value=="")
		error+="Province/State\n";

	if(document.frmContactus.zip.value=="")
		error+="Postal/Zip\n";


	
	if(document.frmContactus.hphone.value=="")
		error+="Home Phone\n";
		
	
		
		
	if(document.frmContactus.comment.value=="")
		error+="Questions/Comments\n";
	
	if(error!="")
		alert("Error! Please check:\n"+error);
	else
		document.frmContactus.submit();
	
	return;
}


<!-- END FORM VALIDATION -->