JQuery Validation Plugin Verification plug-in manual validation _jquery

Source: Internet
Author: User

Jquery.validate is a validation framework for jquery, with the advantage of jquery, we can quickly verify some of the common input, and we can expand our own authentication methods, and international also have good support.

The normal authentication mode is as follows:

<form id= "ff" action= "XXX" > ... 
<input type= "Submit" value= "Submission" > 
</form> 
[Java] View plaincopy see the code on the codes derived from my Code slice

So just click on the Submit button and the plugin will be validated automatically.

But sometimes we want to click on the other buttons to verify the form, and then do the rest based on the validation results of the form.

See the source found that there is a form () method, this method is to perform the validation operation, although the method literal meaning is not very consistent.

Then we can do this:

Var validator;//declares a global variable 
$ (function () { 
validator = $ (' #ff '). Validate ();//This sentence returns an object 
}) 
function Add () { 
var b = validator.form ();//Return a Boolean value 
if (b) {//Verify success 
//Do add ... 
} 
} 

If validation fails, an error message is displayed, and if you want to clear the error message, you can call Validator.resetform ();

With the Validator.form () and Validator.resetform () Two methods , we can use the verification plugin flexibly.

Validating fields

required– Required Fields

remote– Remote Authentication

minlength– Minimum Length verification

maxlength– Maximum length verification

rangelength– Length Range Verification

min– Minimum Value verification

max– max value Verification

range– Range Value Validation

email– Email Address Verification

Url–url Address Verification

date– Date Validation

Dateiso–iso Date Format Validation

number– decimal Number Verification

digits– Digital Verification

creditcard– Credit card number verification

Value equality validation for equalto– and another text box

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.