JQuery Validate Submission Form validation Failure extension method

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.