Hello,
I'm having trouble resetting the validation state of a form after a submit event.
Currently, I use the following resetting code:
form[0].reset();
_validator.resetForm();
_validator.submitted = {};
This works as expected, resets the form and clears the previous error messages. However, the plugin (or the form itself?) still seems to remember that the submit button of the form was already pressed once. Validation is set to eager right from the start and corrects everything immediately. The default behavior of my code is to wait until submit was pressed and then start eager validation.
For better understanding, here's a small example of what exactly it is I'm doing:
$(document).ready(function(){
var _validator;
$('#content').load('form.jsp', function() {
var oForm = document.forms[0];
_validator = $(oForm).validate({
onkeyup: false,
rules: {
user: "required",
newpass1: "required",
newpass2: {
required: true,
equalTo: "#newpass1"
}
}
});
});
$(document).on('submit', '#form', function(){
if(_validator.valid()){
alert('valid');
form[0].reset();
_validator.resetForm();
_validator.submitted = {};
}
return false;
});
});
Hopefully you can give me a few hints! Thanks a lot!