javascript - Getting issue while doing validation using jQuery with JSON call -
i have 1 text box in view in mvc , have validate text box client side before submit.i'm using jquery validation following:
$("input[type='submit']").click(function () { //validation @ client side //------------------code 1------------------- if ($("#txtname").val() == "") { alert("please enter name."); return false; } //------------------code 1------------------- //------------------code 2------------------- //call database validation $.getjson("/producy/isexist?productname=toy", function (data) { if (data.isexists == "1") { alert("product exist."); return false; } }); //------------------code 2------------------- });
validation working code 1 not code 2 when click on submit message display "product exist" form posted wrote return false
after alert message.why it's doing such type of behavior.
thanks.
Comments
Post a Comment