<!-- hide
//Validator for name, email address and phone number on postform
//C. John Oliver August 2003 john@oliver1.com

function validatemail(addr){
var i=0;
var invalidChars=" /:,;";
if (addr.length < 6){
return false;
}
for(i=0;i<invalidChars.length;i++){
 badChar=invalidChars.charAt(i);
 if (addr.indexOf(badChar,0)>-1){
  return false;
  }
 }
atPos=addr.indexOf("@",1);
 if (atPos==-1){
 return false;
 }
if (addr.indexOf("@",atPos+1)>-1){
 return false;
 }
periodPos=addr.indexOf(".",atPos);
if (periodPos==-1){
 return false;
 }
if (periodPos+3>addr.length){
 return false;
 }
return true;
}

function checkName() {
//define regular expression for matching any chars NOT in list and all possible matches
var checkchars=new RegExp("[^ ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz]","g");
var i;
if (postform.fname.value.length <2){
//alert("Name Failed too short");
return (false);
}
if (checkchars.test(postform.fname.value)){
//alert("Name Failed invalid chars");
return (false);
}
else{
//alert("Name passed");
return (true);
}
}

function checkNumber() {
//define regular expression for matching any chars NOT in list and all possible matches
var checkchars=new RegExp("[^ 0123456789]","g");
//allow blank
if (postform.fphone.value.length ==0){
return (true);
}
//but if there, must be numbers and at least 8
if (postform.fphone.value.length <8){
//alert("Number Failed invalid chars");
return (false);
}
if (checkchars.test(postform.fphone.value)){
//alert("Number Failed invalid chars");
return (false);
}
else{
//alert("Number passed");
return (true);
}
}


function submitform(){
if(!validatemail(document.postform.femail.value)){
	alert("Invalid Email Address");
	document.postform.femail.focus;
	return false;
}
if (!checkName()){
	alert("Please enter your name with letters only")
	document.postform.fname.focus();
	return false;
	}
if (!checkNumber()){
	alert("Please enter your number with digits only")
	document.postform.fphone.focus();
	return false;
	}
if (document.postform.fcomment.value.length>300){
	alert("Please shorten your message");
	document.postform.fcomment.focus();
	return (false);
	}

document.postform.submit();
return true;
}
//-->
