Introduction to JQuery Validate Plug-ins
The JQuery Validate plug-in provides a powerful validation feature for forms, making client form validation simpler, while providing a wide range of customization options to meet the needs of the application. The plug-in bundles a set of useful authentication methods, including URL and email authentication, while providing an API for writing user-defined methods. All bundled methods use English as an error message by default and are translated into 37 other languages.
The plugin is written and maintained by Jörn Zaefferer, a member of the jquery team, the main developer of the jquery UI team, and a qunit maintenance person.
- Official website: http://bassistance.de/jquery-plugins/jquery-plugin-validation/
- online Documentation: http://docs.jquery.com/Plugins/Validation
- Online API: http://jquery.bassistance.de/api-browser/plugins.html
Second, the characteristics of JQuery Validate has introduced
The JQuery Validate has the following features:
(1) built-in validation rules;
Powerful jQuery form verification plug-in for everyday E-mail, phone numbers, URLs, and other validation and Ajax validation, in addition to its own rich validation rules, you can add custom validation rules.
Compatible with IE 6+, Chrome, Firefox, Safari, Opera 10+
(2) custom validation rules;
(3) Simple, powerful information tips.
(4) Real-time validation: KeyUp or Blur events to trigger the checksum, not just the time of the submission of the checksum.
Three simple examples to learn about jquery Validate
These examples are premised on the need to introduce jquery libraries and validation plug-ins.
<script type= "Text/javascript" src= ". /.. /lib/jquery-1.11.1.js "></script>
<script type=" Text/javascript "src=". /.. /dist/jquery.validate.js "></script>
1. Use the plug-in to do some simple verification
The effect is as follows:
Explanation of the above checksum:
1, first need to introduce jquery-1.11.1.js, because this plug-in is based on jquery.
2), the introduction of the verification plug-in jquery.validate.js.
3), introduce a hint localization script. Verify the internationalization of the information, the default validation prompts are in English, import validation has already written internationalized files can be internationalized. Change the error/correct message display style.
4), add the type to verify in the class attribute of the input box. For different fields, the validation rule code, set the corresponding properties of the field
Some of these verifiable rule types:
(1) Required:true required field
(2) Remote: "Check.shtml" using the Ajax method call check.shtml validation input value
(3) Email:true must enter the correct format of the e-mail message ( Only validate format, not guaranteed validity)
(4) Url:true must enter the correct format of the URL
(5) Date:true must enter the correct format of the date
(6) Dateiso:true must enter the correct format of the date (ISO), For example: 2009-06-23, 1998/01/22 only validate format, not verify validity
(7) Number:true must enter a valid number (negative, decimal)
(8) Digits:true must enter an integer
(9) CreditCard: Must enter valid credit card number
(a) Equalto: "#field" input value must be the same as #field
(one) Accept: Enter a string with a legal suffix (the suffix of the uploaded file)
(12) Maxlength:5 enter a string with a maximum length of 5 (Kanji)
(minlength:10) The string with the minimum input length of 10 (Chinese character)
rangelength:[5,10] Input length must be between 5 and 10 (Kanji) (Chinese character) range:[5,10] The input value
must be between 5 and 10
(in) Max:5 input value cannot be greater than 5
min:10 input value cannot be less than 10
5), determine which form needs to be validated
<script type= "Text/javascript" >
////<![ cdata[
$ (document). Ready (function () {
$ ("#commentForm"). Validate ();
]]>
</script>
This article has been organized into the "jquery form verification Encyclopedia," Welcome to learn to read.
The above is for the jquery validate form verification of the introductory study, I hope to help you learn.