I\'m using jQuery Validation plugin to validate a form. Do you know how to force revalidation on previously successful fields?
I have tried the .form fu
I came upon this answer when I was looking into using jQuery remote unobtrusive validation. It wasn't the best documented topic in the world and also it wasn't without quirks. So much so that I ended up writing a blog post about what I learned. Link here in case helpful:
http://icanmakethiswork.blogspot.com/2012/03/jquery-unobtrusive-remote-validation.html
The state of validation for remote fields is stored via $.data() with the element you want to validate, so you could use .removeData() to clear that out...so it's forced to revalidate:
$("#form1 :input").removeData("previousValue");
//now call .valid()
This forces the check if the value has changed (we need to re-validate) to be true
:
//This code is in the validation plugin for remote:
var previous = this.previousValue(element);
if (previous.old !== value) { //this is normally false, since it hasn't changed
If there are only specific fields that need re-validating, like you said username, you may want to narrow the $("#form1 :input")
selector to only the fields you want, to make it a bit more efficient.