function Checkform () { fname = document.frmMessage.fname.value; lname = document.frmMessage.lname.value; email = document.frmMessage.email.value; street = document.frmMessage.street.value; city = document.frmMessage.city.value; state = document.frmMessage.state.value; zip = document.frmMessage.zip.value; acode = document.frmMessage.acode.value; phone1 = document.frmMessage.phone1.value; phone2 = document.frmMessage.phone2.value; comment = document.frmMessage.comment.value; var fname_flag; var lname_flag; var email_flag; var street_flag; var city_flag; var state_flag; var zip_flag; var acode_flag; var phone1_flag; var phone2_flag; var comment_flag; var form_ok; var tapout; var errorfocus; var pstring; var p2string; var form_pass; form_pass = true; form_ok = 0; tapout = 0; errorfocus = 0; fname_flag = 0; lname_flag = 0; email_flag = 0; street_flag = 0; city_flag = 0; state_flag = 0; zip_flag = 0; acode_flag = 0; phone1_flag = 0; phone2_flag = 0; comment_flag = 0; //check for empty spaces or less than values, error condition 1 if (fname.length < 2) fname_flag = 1; if (lname.length < 2) lname_flag = 1; if (email < 4) email_flag = 1; if (street == "") street_flag = 1; if (city.length < 3) city_flag = 1; if (state == "") state_flag = 1; if (zip == "") zip_flag = 1; if (acode == "") acode_flag = 1; if (phone1 == "") phone1_flag = 1; if (phone2 == "") phone2_flag = 1; if (state == "empty") state_flag = 1; if (comment == "") comment_flag = 1; //check for incorrect values, error condition 2 if (acode_flag == 0){ if (isNaN(acode) == true) acode_flag = 2; } if (phone1_flag == 0){ if (isNaN(phone1) == true) phone1_flag = 2; } if (phone2_flag == 0){ if (isNaN(phone2) == true) phone2_flag = 2; } if (fname_flag == 0){ if (isNaN(fname) == false) fname_flag = 2; } if (lname_flag == 0){ if (isNaN(lname) == false) lname_flag = 2; } if (street_flag == 0){ if (isNaN(street) == false) street_flag = 2; } if (city_flag == 0){ if (isNaN(city) == false) city_flag = 2; } if (zip_flag == 0){ if (isNaN(zip) == true) zip_flag = 2; } if (email_flag == 0){ if (email.indexOf("@",0) == -1) email_flag = 2; if (email.indexOf(".",0) == -1) email_flag = 2; } //check for incomplete values, error condition 3 if (acode_flag == 0){ if (acode.length < 3) acode_flag = 3; } if (phone1_flag == 0){ if (phone1.length < 3) phone1_flag = 3; } if (phone2_flag == 0){ if (phone2.length < 4) phone2_flag = 3; } if (zip_flag == 0){ if (zip.length < 5) zip_flag = 3; } form_ok = fname_flag + lname_flag + email_flag + street_flag + city_flag + state_flag + zip_flag + acode_flag + phone1_flag + phone2_flag + comment_flag; //error messages if (form_ok > 0){ //type 1 error condition if ((fname_flag == 1) && (tapout == 0)){ window.alert("YOUR FIRST NAME MUST BE AT LEAST 2 CHARACTERS"); tapout = 1; errorfocus = 1; } if ((lname_flag == 1) && (tapout == 0)){ window.alert("YOUR LAST NAME MUST BE AT LEAST 2 CHARACTERS"); tapout = 1; errorfocus = 2; } if ((street_flag == 1) && (tapout == 0)){ window.alert("PLEASE ENTER YOUR STREET ADDRESS"); tapout = 1; errorfocus = 4; } if ((city_flag == 1) && (tapout == 0)){ window.alert("PLEASE ENTER A VALID CITY"); tapout = 1; errorfocus = 5; } if ((email_flag == 1) && (tapout == 0)){ window.alert("PLEASE ENTER YOUR EMAIL ADDRESS"); tapout = 1; errorfocus = 3; } if ((state_flag == 1) && (tapout == 0)){ window.alert("PLEASE SELECT YOUR STATE"); tapout = 1; errorfocus = 6; } if ((zip_flag == 1) && (tapout == 0)){ window.alert("PLEASE ENTER YOUR ZIP"); tapout = 1; errorfocus = 7; } if ((acode_flag == 1) && (tapout == 0)){ window.alert("PLEASE ENTER YOUR AREA CODE"); tapout = 1; errorfocus = 8; } if ((phone1_flag == 1) && (tapout == 0)){ window.alert("PLEASE ENTER THE FIRST THREE DIGITS OF YOUR TELEPHONE NUMBER"); tapout = 1; errorfocus = 9; } if ((phone2_flag == 1) && (tapout == 0)){ window.alert("PLEASE ENTER THE LAST FOUR DIGITS OF YOUR TELEPHONE NUMBER"); tapout = 1; errorfocus = 10; } if ((comment_flag == 1) && (tapout == 0)){ window.alert("PLEASE ENTER A MESSAGE"); tapout = 1; errorfocus = 11; } //type 2 error condition if((acode_flag == 2) && (tapout == 0)){ window.alert("PLEASE ENTER A THREE DIGIT NUMBER FOR THE AREA CODE"); tapout = 1; errorfocus = 8; } if((phone1_flag == 2) && (tapout == 0)){ window.alert("PLEASE ENTER NUMBERS FOR THE FIRST THREE DIGITS OF YOUR TELEPHONE NUMBER"); tapout = 1; errorfocus = 9; } if((phone2_flag == 2) && (tapout == 0)){ window.alert("PLEASE ENTER NUMBERS FOR THE LAST FOUR DIGITS OF YOUR TELEPHONE NUMBER"); tapout = 1; errorfocus = 10; } if((zip_flag == 2) && (tapout == 0)){ window.alert("PLEASE ENTER ONLY NUMBERS IN THE ZIP CODE FIELD"); tapout = 1; errorfocus = 7; } if((fname_flag == 2) && (tapout == 0)){ window.alert("PLEASE DO NOT ENTER NUMBERS IN THE FIRST NAME FIELD"); tapout = 1; errorfocus = 1; } if((lname_flag == 2) && (tapout == 0)){ window.alert("PLEASE DO NOT ENTER NUMBERS IN THE LAST NAME FIELD"); tapout = 1; errorfocus = 2; } if((street_flag == 2) && (tapout == 0)){ window.alert("PLEASE ENTER A VALID ADDRESS"); tapout = 1; errorfocus = 4; } if((email_flag == 2) && (tapout == 0)){ window.alert("PLEASE ENTER A VALID EMAIL"); tapout = 1; errorfocus = 3; } if((city_flag == 2) && (tapout == 0)){ window.alert("PLEASE DO NOT ENTER NUMBERS IN THE CITY FIELD"); tapout = 1; errorfocus = 5; } //type 3 error condition if((acode_flag == 3) && (tapout == 0)){ window.alert("AREA CODE FIELD IS INCOMPLETE"); tapout = 1; errorfocus = 8; } if((phone1_flag == 3) && (tapout == 0)){ window.alert("THE FIRST THREE DIGITS FIELD OF YOUR TELEPHONE NUMBER IS INCOMPLETE"); tapout = 1; errorfocus = 9; } if((phone2_flag == 3) && (tapout == 0)){ window.alert("THE LAST FOUR DIGITS OF FIELD OF YOUR TELEPHONE NUMBER IS INCOMPLETE"); tapout = 1; errorfocus = 10; } if((zip_flag == 3) && (tapout == 0)){ window.alert("THE ZIP CODE FIELD IS INCOMPLETE"); tapout = 1; errorfocus = 7; } } //set focus if (form_ok != 0){ switch (errorfocus){ case 1: document.frmMessage.fname.focus(); break; case 2: document.frmMessage.lname.focus(); break; case 3: document.frmMessage.email.focus(); break; case 4: document.frmMessage.street.focus(); break; case 5: document.frmMessage.city.focus(); break; case 6: document.frmMessage.state.focus(); break; case 7: document.frmMessage.zip.focus(); break; case 8: document.frmMessage.acode.focus(); break; case 9: document.frmMessage.phone1.focus(); break; case 10: document.frmMessage.phone2.focus(); break; case 11: document.frmMessage.comment.focus(); break; default: break; } } //kill form if (form_ok > 0) form_pass = false; return form_pass; }