function validationfrm(theForm) { if (theForm.tbfname.value == "") { alert("Please Enter FirstName"); theForm.tbfname.focus(); return false; } if (theForm.tblname.value == "") { alert("Please Enter Last Name"); theForm.tblname.focus(); return false; } if (theForm.tbcompany.value == "") { alert("Please Enter Company Name"); theForm.tbcompany.focus(); return false; } if (theForm.tbaddress.value == "") { alert("Please Enter Address"); theForm.tbaddress.focus(); return false; } if (theForm.tbcity.value == "") { alert("Please Enter City"); theForm.tbcity.focus(); return false; } if (theForm.ltstate.value == "N/A") { alert("Please Select State"); theForm.ltstate.focus(); return false; } if (theForm.tbzip.value == "") { alert("Please Enter Zip Code"); theForm.tbzip.focus(); return false; } if (theForm.tbzip.value.length > 0) { if (!(validateUSZip(theForm.tbzip.value))) { alert("Invalid Zip Code"); theForm.tbzip.focus(); return false; } } if (theForm.tbtelephone.value == "") { alert("Please Enter Phone Number"); theForm.tbtelephone.focus(); return false; } if (theForm.tbtelephone.value.length > 0) { if (!(check_usphone(theForm.tbtelephone.value))) { alert("Invalid Phone Number"); theForm.tbtelephone.focus(); return false; } } if (theForm.tbfax.value.length > 0) { if (!(check_usphone(theForm.tbfax.value))) { alert("Invalid Fax Number"); theForm.tbfax.focus(); return false; } } if (theForm.tbemail.value.length == 0) { alert("Please Enter Email"); theForm.tbemail.focus(); return false; } if (theForm.tbemail.value.length > 0) { if (!(emailCheck (theForm.tbemail.value))) { theForm.tbemail.focus(); return false; } } if (theForm.ltreference.value == "N/A") { alert("Please select where you hear about us"); theForm.ltreference.focus(); return false; } if(theForm.tbsource2.style.visibility=='visible' && theForm.tbsource2.value.length == 0) { alert("Please enter a value for the \""+window.lbsource2.innerHTML+"\" field."); theForm.tbsource2.focus(); return false; } if(theForm.tbsource3.style.visibility=='visible' && theForm.tbsource3.value.length == 0) { alert("Please enter a value for the \""+window.lbsource3.innerHTML+"\"field."); theForm.tbsource3.focus(); return false; } if (!((theForm.chktype1.checked) || (theForm.chktype2.checked) || (theForm.chktype3.checked) || (theForm.chktype4.checked) || (theForm.chktype5.checked) || (theForm.chktype6.checked) || (theForm.chktype7.checked) || (theForm.chktype8.checked) || (theForm.chktype9.checked) || (theForm.chktype10.checked) || (theForm.chktype11.checked) || (theForm.chktype12.checked) || (theForm.chktype13.checked) || (theForm.chktype14.checked) || (theForm.chktype15.checked))) { //if (!(theForm.chktype1.checked)) { alert("Please select a business type"); return false; } if ((theForm.tbseccode.value == "")||(theForm.tbseccode.value!=theForm.SecurityCode.value)) { alert("Please correctly enter the security code"); theForm.tbseccode.focus(); return false; } return true; } function emailCheck (emailStr) { var emailPat=/^(.+)@(.+)$/ var specialChars="\\(\\)<>@,;:\\\\\\\"\\.\\[\\]" var validChars="\[^\\s" + specialChars + "\]" var firstChars=validChars var quotedUser="(\"[^\"]*\")" var ipDomainPat=/^\[(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})\]$/ var atom="(" + firstChars + validChars + "*" + ")" var word="(" + atom + "|" + quotedUser + ")" var userPat=new RegExp("^" + word + "(\\." + word + ")*$") var domainPat=new RegExp("^" + atom + "(\\." + atom +")*$") var matchArray=emailStr.match(emailPat) if (matchArray==null) { alert("Email address seems incorrect (check @ and .'s)"); return false; } var user=matchArray[1] var domain=matchArray[2] if (user.match(userPat)==null) { alert("The username doesn't seem to be valid."); return false; } var IPArray=domain.match(ipDomainPat) if (IPArray!=null) { for (var i=1;i<=4;i++) { if (IPArray[i]>255) { alert("Destination IP address is invalid!"); return false; } } return true; } var domainArray=domain.match(domainPat) if (domainArray==null) { alert("The domain name doesn't seem to be valid."); return false; } var atomPat=new RegExp(atom,"g") var domArr=domain.match(atomPat) var len=domArr.length if (domArr[domArr.length-1].length < 2 || domArr[domArr.length-1].length >3) { alert("The address must end in a three-letter domain, or two letter country."); return false; } if (domArr[domArr.length-1].length==2 && len < 3) { var errStr="This address ends in two characters, which is a country" errStr+=" code. Country codes must be preceded by "; errStr+="a hostname and category (like com, co, pub, pu, etc.)"; alert(errStr); return false; } if (domArr[domArr.length-1].length==3 && len < 2) { var errStr="This address is missing a hostname!" alert(errStr); return false; } return true; } function check_usphone(phonenumber) { var objRegExp1 =/^[]*[1]{0,1}[-]{0,1}[ ]*[(]{0,1}[ ]*[0-9]{3,3}[ ]*[)]{0,1}[-]{0,1}[ ]*[0-9]{3,3}[ ]*[-]{0,1}[ ]*[0-9]{4,4}[ ]*$/; //var objRegExp2 =/^[ ]*[0-9]{3,3}[ ]*[-]{0,1}[ ]*[0-9]{4,4}[ ]*$/ return (objRegExp1.test(phonenumber)); /************************************************ if(!useareacode)useareacode=1; if((phonenumber.match(/^[ ]*[(]{0,1}[ ]*[0-9]{3,3}[ ]*[)]{0,1}[-]{0,1}[ ]*[0-9]{3,3}[ ]*[-]{0,1}[ ]*[0-9]{4,4}[ ]*$/)==null) && ((useareacode!=1) && (phonenumber.match(/^[ ]*[0-9]{3,3}[ ]*[-]{0,1}[ ]*[0-9]{4,4}[ ]*$/)==null))) return false; return true; //The function will return true for any // alphanumeric string with the following // sequence of characters: // any number of spaces [optional], a single // open parentheses [optional], any number of // spaces [optional], 3 digits (area // code), any number of spaces [optional], a // single close parentheses [optional], a single // dash [optional], any number of spaces // [optional], 3 digits, any number of spaces // [optional], a single dash [optional], any // number of spaces [optional], 4 digits, any // number of spaces [optional]. *************************************************/ } function validateUSZip( strValue ) { /************************************************ DESCRIPTION: Validates that a string a United States zip code in 5 digit format or zip+4 format. 99999 or 99999-9999 PARAMETERS: strValue - String to be tested for validity RETURNS: True if valid, otherwise false. *************************************************/ var objRegExp = /(^\d{5}$)|(^\d{5}-\d{4}$)/; //check for valid US Zipcode return objRegExp.test(strValue); }