Reputation: 1428
I have a form that with a validator that works the first time but not the second time. The code validates on the client side without any problem but as soon as the form is submitted and the form is partially render although fields are invalid the $('form').valid() continues returning true always.
The data is validated at the server side but then the error is displayed twice. My rules are set by MVC4 generated code thus rules are correctly initiated.
Not sure if is possible re-validate the form. Please note that $('form').validate() does not work. It returns the validator and valid() returns true all the time.
Here the options. displayErrors function find the html element that shows the errors.
/* Set additional settings for the validator */
var options = {
onfocusout: false,
onkeyup: false,
onclick: false,
showErrors: function (errorMap, errorList) {
displayErrors(errorList, false);
}
};
Help is appreciated.
Upvotes: 0
Views: 800
Reputation: 1428
I solved this by doing something like this
$vlt = $('#myForm').validate(); //-- get validator
$vlt.checkForm();
if ( $('#myForm').valid()){
//-- code
}
It seems like doing it in this way the validator was able to picked the new changes. Not sure if I mention that the form was being re-render and replaced by $('#okok').html(newStuff);
Anyway, I could maybe conclude, I won't recommend this plugin to a friend :))
Upvotes: 1