rendered paste body<script language="JavaScript">
var MinDebt = 9000.00;
function fnEnterInfo()
{
if (fnValidateEmp() && fnValidateEmail() && fnValidatePhones())
{
frmShortForm.submit();
}
}
function fnValidateEmp()
{
FormName = "frmShortForm";
FeildsNames = new Array("F_NAME","L_NAME","E_MAIL","HOME_PHONE1","CF2","CF3");
for(i=0;i<FeildsNames.length;i++)
{
if (eval(FormName + "."+ FeildsNames[i]+ ".value == ''"))
{
if (FeildsNames[i] != 'TOTAL_DEBT')
{
alert("Please fill out all required fields!");
eval(FormName + "." + FeildsNames[i] + ".focus()");
return false;
}
else
{
if (document.getElementById("TOTAL_DEBT_V").value == '')
{
alert("Please fill out all required fields!");
document.getElementById("TOTAL_DEBT_V").focus();
return false;
}
}
}
}
return true;
}
function fnValidatePhones()
{
Phone1RegExp = /^(\d{3})$/;
Phone2RegExp = /^(\d{4})$/;
FormName = "frmShortForm";
FeildsNames = new Array("HOME_PHONE","WORK_PHONE", "CELL_PHONE");
for(i=0;i<FeildsNames.length;i++)
{
if (eval(FormName + "."+ FeildsNames[i]+ "1.value == ''") && eval(FormName + "."+ FeildsNames[i]+ "2.value == ''") && eval(FormName + "."+ FeildsNames[i]+ "3.value == ''")) continue;
if (eval("!Phone1RegExp.test(" + FormName + "."+ FeildsNames[i]+ "1.value)"))
{
alert("You have entered incorrect information in one of the following field(s): Home Phone, Work phone, Cell phone!");
eval(FormName + "." + FeildsNames[i] + "1.focus()");
return false;
}
if (eval("!Phone1RegExp.test(" + FormName + "."+ FeildsNames[i]+ "2.value)"))
{
alert("You have entered incorrect information in one of the following field(s): Home Phone, Work phone, Cell phone!");
eval(FormName + "." + FeildsNames[i] + "2.focus()");
return false;
}
if (eval("!Phone2RegExp.test(" + FormName + "."+ FeildsNames[i]+ "3.value)"))
{
alert("You have entered incorrect information in one of the following field(s): Home Phone, Work phone, Cell phone!");
eval(FormName + "." + FeildsNames[i] + "3.focus()");
return false;
}
}
return true;
}
function fnValidateEmail()
{
EmailRegExp = /^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,4})+$/;
FormName = "frmShortForm";
FeildsNames = new Array("E_MAIL");
for(i=0;i<FeildsNames.length;i++)
{
if (eval(FormName + "."+ FeildsNames[i]+ ".value == ''")) continue;
if (eval("!EmailRegExp.test(" + FormName + "."+ FeildsNames[i]+ ".value)"))
{
alert("Please input correct e-mail!");
eval(FormName + "." + FeildsNames[i] + ".focus()");
return false;
}
}
return true;
}
function isUSACurr(string)
{
reCurrencyWithCommas = /^\$?\d{1,3}(,\d{3})*(\.\d{1,2})?$/;
reCurrencyWithoutCommas = /^\$?\d+(\.\d{1,2})?$/;
if ((reCurrencyWithCommas.test(string)) || (reCurrencyWithoutCommas.test(string))) return true
else return false;
}
function formatCurrency(num)
{
num = num.toString().replace(/\$|\,/g,'');
if(isNaN(num)) num = "0";
sign = (num == (num = Math.abs(num)));
num = Math.floor(num*100+0.50000000001);
cents = num%100;
num = Math.floor(num/100).toString();
if(cents<10) cents = "0" + cents;
for (var i = 0; i < Math.floor((num.length-(1+i))/3); i++)
num = num.substring(0,num.length-(4*i+3))+','+
num.substring(num.length-(4*i+3));
return (((sign)?'':'-') + '$' + num + '.' + cents);
}
function ValidateTotalDebt()
{
if (document.getElementById("TOTAL_DEBT_V").value != "")
{
if (!isUSACurr(document.getElementById("TOTAL_DEBT_V").value))
{
alert ("Please check the format of the Amount of Total Debt.");
document.getElementById("TOTAL_DEBT_V").focus();
return false;
}
document.getElementById("TOTAL_DEBT").value = document.getElementById("TOTAL_DEBT_V").value.replace(/\$|\,/g,'');
if (document.getElementById("TOTAL_DEBT").value < MinDebt)
{
alert ("The Total Amount of your Unsecured Debt must be At Least "+formatCurrency(MinDebt)+", please re-enter");
document.getElementById("TOTAL_DEBT_V").focus();
return false;
}
}
return true;
}
</script>