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

前端 未结 2 1917
孤街浪徒
孤街浪徒 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:06

    try this focusout()

    function resetMyForm() {
    
        $('#registerForm').resetForm();
        v.prepareForm();  // Tried adding this, no help
        v.hideErrors();  // Tried adding this, no help
        $("ElementName").focusout(); // focus out  which ever element you want
    

    }

    0 讨论(0)
  • 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/

    0 讨论(0)
提交回复
热议问题