javascript - jQuery Validation giving error with every character entered -
i'm using jquery validator on form on site. functioning properly, every keystroke results in error:
uncaught typeerror: object #<error> has no method 'call' i implementing validation through classes on each field , working - required fields, email fields, numbers, etc.. here validate code:
if(jquery().validate) { //assign global var manual validation validator = $(".validated").validate({ errorclass: "help-inline text-error", errorelement: "span", invalidhandler: function(e, validator) { var errors = validator.numberofinvalids(); if (errors) { var message = errors == 1 ? 'please fix indicated field before saving form.' : 'please fix errors on indicated fields before saving form.'; $(".validation-message").text(message); $(".validation-message").addclass('alert alert-error'); } else { $(".validation-message").removeclass('alert alert-error').text(""); } }, onkeyup: true, submithandler: function(form) { $(".validation-message").removeclass('alert alert-error').text(""); form.submit(); }, errorplacement: function(error, element) { if(element.parent().hasclass('input-append')){ error.insertafter( element.parent() ); }else{ error.insertafter(element); } } }); } can see trigger error without impacting functionality?
cheers!
there no true value onkeyup option.
by default field validation enabled during keyup event. need use option in 2 scenarios
- to disable validation during
keyupevent, in case setonkeyup: false - to customize field validation during
keyup
in case can remove option onkeyup.
Comments
Post a Comment