javascript - Jquery validation does not submit form in once click when ajax call is async -
this question has answer here:
- how return response asynchronous call? 21 answers
- jquery validator , custom rule uses ajax 3 answers
i using jquery validation customized function check duplicate values in database ajax call , ajax call async. issue when fills value , click on submit button directly "without focus out field" form not getting submit though validation function returning true. need click on submit again submit form. below code using: add customized rule:
jquery.validator.addclassrules("checkduplicate", {checkduplicate: true});
the function "checkduplicate" :
$.validator.addmethod("checkduplicate", function (value, element) { var returnvalue = false; $.ajax({ type: "post", async: false, url: '/check-duplicate', data: {value: $('#value').val()}, success: function (response) { if (response.status == true) { returnvalue = false; } else { returnvalue = true; } } }); return returnvalue; }, 'duplicate value');
Comments
Post a Comment