jQuery Validate resetForm() doesn't reset the onFocus validation

前端 未结 2 1922
孤街浪徒
孤街浪徒 2021-01-06 12:30

I have a form that is using jQuery Validate plugin for client side validation, and submits via AJAX. After the form is submitted, I would like it to reset itself. I have u

2条回答
  •  日久生厌
    2021-01-06 13:19

    You need to reset the form and run the Validation plugin method resetForm like this:

    var v = $("form").validate({
        submitHandler: function(form) {
                //resetForm is a method on the validation object, not the form
                v.resetForm(); 
                form.reset();
        }
    });
    

    That seemed to take care of any issues I saw while following your workflow. See this: http://jsfiddle.net/nxXNz/27/

提交回复
热议问题