function trimF(string){return string.replace(/^\s+/,'');}
function validate(theForm){var emailExp=/^[\w\-\.\+]+\@[a-zA-Z0-9\.\-]+\.[a-zA-z0-9]{2,4}$/;var phoneNumberPattern=/^\(?(\d{3})\)?[- ]?(\d{3})[- ]?(\d{4})$/;if(theForm.fname.value==""){alert("Please enter your First Name.");theForm.fname.focus();return false;}
if(theForm.lname.value==""){alert("Please enter your Last Name.");theForm.lname.focus();return false;}
if(!theForm.email.value.match(emailExp)){alert("Not a Valid Email!");theForm.email.focus();return false;}
if(!theForm.phone.value.match(phoneNumberPattern)){alert("Please enter a valid phone number.\nDon't forget the area code!");theForm.phone.focus();return false;}
if(theForm.address.value==""){alert("Please enter your Address.");theForm.address.focus();return false;}
if(theForm.citystate.value=="Please enter valid zipcode!"){alert("Please enter your correct zipcode.");theForm.citystate.focus();return false;}
if(theForm.zip.value==""){alert("Please enter your Zip.");theForm.zip.focus();return false;}
if(theForm.title.value==""||trimF(theForm.title.value).length<5){alert("Please enter your job title.");theForm.title.focus();return false;}
if(theForm.companyname.value==""||trimF(theForm.companyname.value).length<5){alert("Please enter your company name.");theForm.companyname.focus();return false;}
if(theForm.program.value==""){alert("Please choose a program.");theForm.program.focus();return false;}
theForm.submit();}