views:

48

answers:

1

Here is the js file. The function SubmitCheck is running but when there is a state, I want to do the address check and it doesn't appear to run. What am I doing wrong?

Thanks, ck in San Diego

var prm = null;

Sys.Application.add_init(Init);

function Init(sender) {

    prm = Sys.WebForms.PageRequestManager.getInstance();

    WireEvents();

}

function WireEvents() {
    var submit = $("#btnSubmit");

    submit.click(SubmitCheck);

}

function SubmitCheck(){
    var hasState = DoStateCheck();

    if (!hasState) {
        prm.abortPostBack();
        return false;
    } else {
        var addressCheck = DoAddressCheck();
        alert(addressCheck);
    }

    if (!addressCheck) {
        prm.abortPostBack();
        return false;
    }
}

function DoAddressCheck(){

    var add1 = $("#txtAddressMaintLine1");
    if (add1.val().length < 1) {
        return confirm("No Address was detected.\nClick OK to proceed or Cancel to provide an address.");
    }

    return;
}

function DoStateCheck() {

      var tb = $("#txtState");
      if (tb.val().length < 2) {
          alert("A state must be provided when establishing a claim.");
          tb.focus();
          return false;
      }

      return;
}
+1  A: 

Maybe replace

return;

in DoStateCheck() with

return true;

?

jitter
Thanks man. That worked just fine of course.
Hcabnettek