JQuery Verification Form format, jquery Verification Form

Source: Internet
Author: User
Tags file url

JQuery Verification Form format, jquery Verification Form

After work, sort out some code written in the work, record the technical points in the work, so that you can remember the integration. The following are some of the jQuery verification markup and usage methods:

The entire js Code is put into jquery_validate_1.1.0.js. Using an anonymous function and jQuery extension method, the extension method is the initValidate function. The method includes an options configuration parameter. Currently, the configuration parameter has only one attribute, {handlerUrl: ""}: Specifies whether the url for backend request verification is required. You only need to bind $ ("ID"). initValidate (options) to the DOM to be verified ). Add custom properties to the input control. The custom property rules are as follows:

<Div id = "panda">
<Input type = "text" validate = "true" ctr-type = "mobile"/>
</Div>

The preceding simple demo verifies whether the input format is a mobile phone number. If the entered information does not comply with the rules, the error message will prompt the next line in the input box, for example:

 

1 validate = "true" // perform verification. If this parameter is not set to true, other attributes are not verified; 2 isrequired = "true" // required. 3 checkunique = "true" // backend Ajax uniqueness verification. If not unique, the verification fails; 4 ctr-type = "email" // The format is email, pwd: Password, char: Name, number: number, float: decimal number, mobile: mobile Phone, idcard: ID card; 5 repeatpwd = "true" // password repeatability check. This label must appear in both the passwords to be verified and the password control must be repeatedly entered. 6. Initialization example: 7 $ ('# panda '). initValidate (); 8 verify all input before submitting the button: 9 $ ('. okbtn '). click (function () {return $ ('# panda '). validateAllControls ()}); 10 example of Email Verification: 11 <input type = "text" ctr-type = "email" checkunique = "true" isrequired = "true" validate = "true" name = "myEmail" id = "myEmail" /> 12 <label class = "error"> </label> 13 password verification example: 14 <input type = "password" ctr-type = "pwd" isrequired = "true" validate = "true" repeatpwd = "true" name = "newPassword"/> 15 <label class = "error"> </label>
View Code

 

In the preceding verification, the precondition is validate = "true". This attribute is used to verify all other rules. If this attribute is not set, no other settings are verified. This jquery verification is a verification event where the cursor loses focus.

If you need to manually call the verification, call the separate verification method: $ ("# panda"). validateAllControls (options); the custom settings in the input box are the same as those above.

File url path: Success.

 

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.