Validation does not pass the triggering method because validate does not provide a form submission. Here's a little bit of expansion.
Reference scenario: Validation of the form element each time it is submitted does not pass the trigger method
Open the source code to find the Focusinvalid method, here is the submission of the form validation does not pass the trigger method, where the extension is good.
Focusinvalid:function () {
if (this.settings.focusInvalid) {
try {
$ (this.findlastactive () | | this.errorList.length && this.errorlist[0].element | | [])
. Filter (": Visible")
. Focus ()
. Trigger ("Focusin");
/* Extension Method Failedcallback */
var failedcallback=this.settings.failedcallback;
if ($.type (failedcallback) = = = ' function ') {
Failedcallback (this.errorlist);
}
} catch (e) {
}
}
}
Use
$ (' #editForm '). Validate (
{
Rules: ...,
Failedcallback:function (errorlist) {
Loop validation failed Element
for (var i=0; i<errorlist.length; i++) {
var element=errorlist[0].element;
if (Element). attr ("name") = = ' Birthday ') {
........................................
}
}
}
}
);
This article is from a "concise" blog, so be sure to keep this source http://201510240609.blog.51cto.com/5178830/1933670
JQuery Validate Submission Form validation Failure extension method