Jquery. validate introduction 3_jquery

Source: Internet
Author: User
Customize the validation behavior of jquery-validate 1: custom form submission

Set submitHandler to customize the form submission action

$ (". Selector"). validate ({
SubmitHandler: function (form) {alert ("verified ");}
});

To submit a form, call
Form. submit (); or $ (form). ajaxSubmit ();

2: debugging mode

Set debug to true, and the form is not submitted. Check only to facilitate debugging.

$ (". Selector"). validate ({
Debug: true
})

3: Set the default value of validate

You can use setDefaults to set the default value of validate. For example, all form verification tasks are performed in debug mode by default.

$. Validator. setDefaults ({
Debug: true
})

4: some elements are not verified.

You can set the ignore attribute to ignore some elements that are not verified.

$ (". Selector"). validate ({
Ignore: "ignore"
})

5: verification time

Jquery. validate allows you to easily set when verification actions are triggered.

Onsubmit: whether to verify when submitting

$ (". Selector"). validate ({
Onsubmit: false
})

Onfocusout: verification when the focus is lost (except for checkboxes/radio)

$ (". Selector"). validate ({
Onfocusout: false
})

Onkeyup: verification during keyup

$ (". Selector"). validate ({
Onkeyup: false
})

Onclick: Verify when checkboxes and radio are clicked.

$ (". Selector"). validate ({
Onclick: false
})

6. Rewrite verification rules and verification prompt information.

// Rewrite the verification prompt information of max.
$. Validator. messages. max = jQuery. format ("Your totals musn't exceed {0 }! ");

// Rewrite the equal Method
$. Validator. methods. equal = function (value, element, param ){
Return value = param;
};

7: Does focusInvalid focus on the last action or the last error?

$ (". Selector"). validate ({
FocusInvalid: false
})

8: focusCleanup

If this attribute is set to True, when the control obtains the focus, it removes the wrong class definition and hides the error information to avoid using it with focusInvalid.

$ (". Selector"). validate ({
FocusCleanup: true
})

9: meta

Set meta to encapsulate verification rules

$ (". Selector"). validate ({
Meta: "validate ",
})
Related Article

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.