

<!----------------------------------------------------------------------------->
//Make sure email address has a period and @ as in davef@maui.net
//but we will also allow a blank password
function CheckForValidEmailAddress(FormField)
{
if (FormField==null)        //if field does not exist we can't check it
  return true;
else
  {
  if (IsFieldBlank(FormField))
    return true;
  else
    return (FormField.value.indexOf("@") != -1 &&
            FormField.value.indexOf(".") != -1);
  }
}

<!----------------------------------------------------------------------------->
function IsFieldBlank(FormField)
{
//make sure the FormField exists or FormField.valu will raise an exception
if (FormField==null)        //if field does not exist we can't check it
  return false;
else
  {
  return (FormField.value == "" || FormField.value == null || FormField.value == "-- Please Select --" || FormField.value == "Please Select");
  }
}

<!----------------------------------------------------------------------------->
function IsSelectBlank(FormField)
{
if (FormField==null)      //if field does not exist we can't check it
  return false;
else
  return (FormField.options[FormField.selectedIndex].text == "" || FormField.options[FormField.selectedIndex].text == null || FormField.options[FormField.selectedIndex].text == "-- Please Select --" || FormField.options[FormField.selectedIndex].text == "Please Select");
}


<!----------------------------------------------------------------------------->
function CheckApplicationRequiredFields(form)
{

if (IsSelectBlank(form.ProgramName))
  {
  form.ProgramName.focus();
  alert("The 'Program' field is required and must be completed before clicking the submit button.");
  return false;
  }
if (IsFieldBlank(form.TargetRate))
  {
  form.TargetRate.focus();
  alert("The 'TargetRate' field is required and must be completed before clicking the submit button.");
  return false;
  }
if (IsSelectBlank(form.DocType))
  {
  form.DocType.focus();
  alert("The 'Doc Type' field is required and must be completed before clicking the submit button.");
  return false;
  }
if (IsFieldBlank(form.AffiliateName))
  {
  form.AffiliateName.focus();
  alert("The 'Affiliate Name' field is required and must be completed before clicking the submit button.");
  return false;
  }
if (CheckForValidEmailAddress(form.AffiliateEmail) == false) {
    form.AffiliateEmail.focus();
    alert("The Affiliate E-Mail Address you entered do not appear to be valid.  Please enter a valid Affiliate E-mail Address.");
    return false;
    }
if (IsSelectBlank(form.LenderContact))
  {
  form.LenderContact.focus();
  alert("The 'Lender Contact' field is required and must be completed before clicking the submit button.");
  return false;
  }
if (IsFieldBlank(form.AffiliateEmail))
  {
  form.AffiliateEmail.focus();
  alert("The 'Affiliate E-Mail' field is required and must be completed before clicking the submit button.");
  return false;
  }

if (IsFieldBlank(form.BorrowerFirstName))
  {
  form.BorrowerFirstName.focus();
  alert("Please complete the Borrower First Name so that we may contact you about your application.");
  return false;
  }
if (IsFieldBlank(form.BorrowerLastName))
  {
  form.BorrowerLastName.focus();
  alert("Please complete the Borrower Last Name so that we may contact you about your application.");
  return false;
  }
if (IsFieldBlank(form.BorrowerBirthDate))
  {
  form.BorrowerBirthDate.focus();
  alert("Please complete the Borrower Birth Date field.");
  return false;
  }
if (IsSelectBlank(form.BorrowerMaritalStatus))
  {
  form.BorrowerMaritalStatus.focus();
  alert("The 'Borrower Marital Status' field is required and must be completed before clicking the submit button.");
  return false;
  }
if (IsSelectBlank(form.BorrowerUSCitizen))
  {
  form.BorrowerUSCitizen.focus();
  alert("The 'Borrower US Citizen' field is required and must be completed before clicking the submit button.");
  return false;
  }
if (IsFieldBlank(form.BorrowerSocialSecurityNumber1))
  {
  form.BorrowerSocialSecurityNumber1.focus();
  alert("The 'Borrower Social Security Number' field is required and must be completed before clicking the submit button.");
  return false;
  }
if (CheckForValidEmailAddress(form.EmailAddress) == false) {
    form.EmailAddress.focus();
    alert("The Borrower E-Mail Address you entered do not appear to be valid.  Please enter a valid E-mail Address.");
    return false;
    }
if (IsFieldBlank(form.CurrentAddress))
  {
  form.CurrentAddress.focus();
  alert("The 'Borrower Current Address' field is required and must be completed before clicking the submit button.");
  return false;
  }
if (IsFieldBlank(form.CurrentAddressCity))
  {
  form.CurrentAddressCity.focus();
  alert("The 'Borrower Current Address City' field is required and must be completed before clicking the submit button.");
  return false;
  }
if (IsFieldBlank(form.CurrentAddressState))
  {
  form.CurrentAddressState.focus();
  alert("The 'Borrower Current Address State' field is required and must be completed before clicking the submit button.");
  return false;
  }
if (IsFieldBlank(form.CurrentAddressZip))
  {
  form.CurrentAddressZip.focus();
  alert("The 'Borrower Current Address Zip' field is required and must be completed before clicking the submit button.");
  return false;
  }
if (IsFieldBlank(form.CurrentAddressNumberOfYears))
  {
  form.CurrentAddressNumberOfYears.focus();
  alert("The 'Borrower Current Address Number Of Years' field is required and must be completed before clicking the submit button.");
  return false;
  }

if ((IsFieldBlank(form.PurchasePrice)) &&
    (IsFieldBlank(form.PurchaseLoanAmount)) &&
    (IsFieldBlank(form.RefinanceLoanAmount)) &&
    (IsFieldBlank(form.TotalToBePaidOff)))
  {
  form.PurchasePrice.focus();
  alert("If this is a Purchase, 'Purchase Price' and 'Loan Amount are required, if this is a Refinance, 'Loan Amount' and 'To be paid off' are required.");
  return false;
  }
if (IsFieldBlank(form.SubjectAddressYearBuilt))
  {
  form.SubjectAddressYearBuilt.focus();
  alert("The 'Year Built' field is required and must be completed before clicking the submit button.");
  return false;
  }
if (IsFieldBlank(form.RefinancePropertyValue))
  {
  form.RefinancePropertyValue.focus();
  alert("The 'Property Value' field is required.");
  return false;
  }
if (IsSelectBlank(form.Income1Type))
  {
  form.Income1Type.focus();
  alert("The 'Income Type' field is required and must be completed before clicking the submit button.");
  return false;
  }
if (IsFieldBlank(form.Income1Years))
  {
  form.Income1Years.focus();
  alert("The 'Years on Job' field is required and must be completed before clicking the submit button.");
  return false;
  }
if (IsFieldBlank(form.Income1Amount))
  {
  form.Income1Amount.focus();
  alert("The 'Gross Monthly Income' field is required and must be completed before clicking the submit button.");
  return false;
  }
if ((IsFieldBlank(form.Deposits)) &&
    (IsFieldBlank(form.RealEstateNetProceeds)) &&
    (IsFieldBlank(form.Gifts)) &&
    (IsFieldBlank(form.StocksAndBonds)) &&
    (IsFieldBlank(form.Retirement)))
  {
  form.Deposits.focus();
  alert("At least on item from the Liquid Assets section is required and must be completed before clicking the submit button.");
  return false;
  }

if (form.DataPrinted!=null)        //if field does not exist we can't check it
  {
  if (form.DataPrinted.options[form.DataPrinted.selectedIndex].text == "No")
    {
    alert("You must print this screen and retain a copy for your records before clicking the Submit button.  To print, select File|Print from your Browser.  Once printed, select 'Yes' in the 'Have you printed' question and submit the data again.");
    form.DataPrinted.focus();
    return false;
    }
  }



return true;
}


<!----------------------------------------------------------------------------->
function CheckRequiredFields(form)
{
if (IsFieldBlank(form.BorrowerFirstName))
  {
  form.BorrowerFirstName.focus();
  alert("Please complete the Borrower First Name so that we may contact you about your application.");
  return false;
  }
if (IsFieldBlank(form.BorrowerLastName))
  {
  form.BorrowerLastName.focus();
  alert("Please complete the Borrower Last Name so that we may contact you about your application.");
  return false;
  }

if (CheckForValidEmailAddress(form.EmailAddress) == false) {
    form.EmailAddress.focus();
    alert("The E-Mail Address you entered do not appear to be valid.  Please enter a valid E-mail Address.");
    return false;
    }

return true;
}
