function submission() { if(validateform(mainform)) { document.mainform.submit(); } } function is_empty(elm) { if (elm.value ==""||elm.value==null||elm.value==0) return false; else return true; } function isInt(elm) { var elmstr = elm.value + ""; if (elmstr == "") return false; for (var i = 0; i < elmstr.length; i++) { if (elmstr.charAt(i) < "0" || elmstr.charAt(i) > "9") { return false; } } return true; } function nozero(strchk) { ndxAt = strchk.indexOf("0"); if (ndxAt==0) { return false; } } function noone(strchk) { ndxAt = strchk.indexOf("1"); if (ndxAt==0) { return false; } } function checkdp() { var strlt=document.mainform.loan_type.value; if (strlt == "Purchase") { if (strdp == "") strdp = 0; strpv = parseInt(strpv, 10); strdp = parseInt(strdp, 10); if (strpv < strdp) { alert("Property value needs to be greater than Down Payment"); return false; } var strlaw = strpv - strdp; } return; } function popup_privacy_policy() { window.open('privacy_policy.htm','','width=600,height=600,scrollbars=yes'); } function checkNumeric(objName,minval, maxval,comma,period,hyphen) { var numberfield = objName; if (chkNumeric(objName,minval,maxval,comma,period,hyphen) == false) { numberfield.value = "0"; numberfield.select(); numberfield.focus(); return false; } else { return true; } } function chkNumeric(objName,minval,maxval,comma,period,hyphen) { var checkOK = "0123456789" + comma + period + hyphen; var checkStr = objName; var allValid = true; var decPoints = 0; var allNum = ""; for (i = 0; i < checkStr.value.length; i++) { ch = checkStr.value.charAt(i); for (j = 0; j < checkOK.length; j++) if (ch == checkOK.charAt(j)) break; if (j == checkOK.length) { allValid = false; break; } if (ch != ",") allNum += ch; } if (!allValid) { alertsay = "Please enter only these values \"" alertsay = alertsay + checkOK + "\" in the \"" + checkStr.name + "\" field. Do not use any symbols or letters such as a comma, period, parentheses or 'abcdefg...'" alert(alertsay); return (false); } } var chkDot = true; var usEmail = true; function checkemail() { var eAddr = document.mainform.email.value; var lenSuffix = (usEmail) ? 4 : 3; var result = false; var ndxAt = ndxDot =ndxDot2 = 0; ndxAt = eAddr.indexOf("@"); ndxDot = eAddr.indexOf(".") ; ndxDot2 = eAddr.lastIndexOf(".") ; if ((ndxDot < 0) || (ndxAt < 0)) alert("Enter valid email"); else if ( (ndxDot2 - 3) < ndxAt) alert("Enter valid email "); else if (eAddr.length < ndxDot2 + lenSuffix) result = (confirm("You have fewer than 3 characters as a domain suffix.\nAre you sure?")); else result=true; return result; return true; } function LengthPhone(msg,ctr) { var s=ctr.value; if (!(s.length == 3)) { var write_; write_ = msg + " has to be three digit"; alert(write_); ctr.focus(); return false; } return true; } function LengthSuffix(msg,ctr) { var s=ctr.value; if (!(s.length == 4)) { var write_; write_ = msg + " has to be four digit"; alert(write_); ctr.focus(); return false; } return true; } function LengthOK(msg,ctr) { var s=ctr.value; if (!(s.length == 5)) { var write_; write_ = msg + " has to be five digit"; alert(write_); ctr.focus(); return false; } return true; } function validateform(form) { if (is_empty(form.first_name)== false) { alert("Please enter your first name."); form.first_name.focus(); return false; } if (is_empty(form.last_name)== false) { alert("Please enter your last name."); form.last_name.focus(); return false; } //if (is_empty(form.address)== false) //{ // alert("Please enter your address."); // form.address.focus(); // return false; //} //if (is_empty(form.city)== false) //{ // alert("Please enter your city."); // form.city.focus(); // return false; //} if (form.State.value == "") { alert("Please select a state."); form.State.focus(); return false; } //if (is_empty(form.zip)== false) //{ // alert("Please enter your zip code."); // form.zip.focus(); // return false; //} //else //{ // checkNumeric(form.zip , 0, 0, '', '', '') // //return false //} //if(!LengthOK("Zip ",form.zip)) //{ // return false; //} if (is_empty(form.home_area_code)== false) { alert("Please enter your primary phone area code."); form.home_area_code.focus(); return false; } else { checkNumeric(form.home_area_code , 0, 0, '', '', ''); } if (nozero(form.home_area_code.value)== false) { alert("Primary phone area code cannot start with a zero"); form.home_area_code.focus(); return false; } if (noone(form.home_area_code.value)== false) { alert("Primary phone area code cannot start with 1"); form.home_area_code.focus(); return false; } if(!LengthPhone("Area code ",form.home_area_code)) { return false; } if (is_empty(form.home_prefix)== false) { alert("Please enter your primary phone number."); form.home_prefix.focus(); return false; } else { checkNumeric(form.home_prefix , 0, 0, '', '', ''); } if ((form.home_prefix.value=="000")||(form.home_prefix.value=="111")||(form.home_prefix.value=="555")||(form.home_prefix.value=="800")||(form.home_prefix.value=="888")||(form.home_prefix.value=="999")) { alert("Prefix cannot contain " + form.home_prefix.value); form.home_prefix.focus(); return false; } if (nozero(form.home_prefix.value)== false) { alert("Prefix cannot start with a zero"); form.home_prefix.focus(); return false; } if (noone(form.home_prefix.value)== false) { alert("Prefix cannot start with 1"); form.home_prefix.focus(); return false; } if(!LengthPhone("Prefix ",form.home_prefix)) { return false; } if (is_empty(form.home_suffix)== false) { alert("Please enter your primary phone number."); form.home_suffix.focus(); return false; } else { checkNumeric(form.home_suffix , 0, 0, '', '', ''); } if(!LengthSuffix("Suffix ",form.home_suffix)) { return false; } //Added by Steven Brucato// if (is_empty(form.work_area_code)== false) { alert("Please enter your secondary phone area code."); form.work_area_code.focus(); return false; } else { checkNumeric(form.work_area_code , 0, 0, '', '', ''); } if (nozero(form.work_area_code.value)== false) { alert("Secondary phone area code cannot start with a zero"); form.work_area_code.focus(); return false; } if (noone(form.work_area_code.value)== false) { alert("Secondary phone area code cannot start with 1"); form.work_area_code.focus(); return false; } if(!LengthPhone("Area code ",form.work_area_code)) { return false; } if (is_empty(form.work_prefix)== false) { alert("Please enter your secondary phone number."); form.work_prefix.focus(); return false; } else { checkNumeric(form.work_prefix , 0, 0, '', '', ''); } if ((form.work_prefix.value=="000")||(form.work_prefix.value=="111")||(form.work_prefix.value=="555")||(form.work_prefix.value=="800")||(form.work_prefix.value=="888")||(form.work_prefix.value=="999")) { alert("Prefix cannot contain " + form.work_prefix.value); form.work_prefix.focus(); return false; } if (nozero(form.work_prefix.value)== false) { alert("Prefix cannot start with a zero"); form.home_work.focus(); return false; } if (noone(form.work_prefix.value)== false) { alert("Prefix cannot start with 1"); form.work_prefix.focus(); return false; } if(!LengthPhone("Prefix ",form.work_prefix)) { return false; } if (is_empty(form.work_suffix)== false) { alert("Please enter your secondary phone number."); form.work_suffix.focus(); return false; } else { checkNumeric(form.work_suffix , 0, 0, '', '', ''); } if(!LengthSuffix("Suffix ",form.work_suffix)) { return false; } if (is_empty(form.email)== false) { alert("Please enter your E-mail."); form.email.focus(); return false; } if (is_empty(form.income)== false) { alert("Please enter your monthly income."); form.income.focus(); return false; } if (form.credit_card.value == "0") { alert("Please select an amount of Unsecure Debt."); form.credit_card.focus(); return false; } btnChecked = false; for (i=0; i