How to implement jQuery plug-in Validation form validation
Today Xiaobian to share with you about the jQuery plug-in Validation form verification of how to achieve the relevant knowledge, detailed content, clear logic, I believe that most people are too aware of this knowledge, so share this article for your reference, I hope you have something to gain after reading this article, let's take a look at it.
Function
1. The required and length of "name" is at least two-digit verification.
two。 Verification of the required and E-mail format for "email".
3. Verification of whether the "URL" is url.
4. Verify whether "your comments" is required.
Result diagram
Examples
Get started quickly * {font-family:Verdana; font-size:96%;} label {width:10em; float:left} label.error {float:none; color:red; padding-left:.5em; vertical-align:top;} p {clear:both} .submit {margin-left:12em;} em {font-weight:bold; padding-right:lem; vertical-align:top;} $(document) .ready (function () {$("# commentForm") .validate ();}) A simple example of a comment with a verification hint
Name *
Email *
Web site
Your comments *
Code analysis
1.jQuery code
$(document) .ready (function () {$("# commentForm") .validate ();})
Lines 1 and 2 import the jQuery class library and the Validation plug-in.
The purpose of line 4 is to execute the code in function after the contemporary code has been loaded
Line 5 is to determine which form needs to be validated.
two。 Encode the verification rules for different fields and set the corresponding properties of the field
Class= "required" is required
Class= "required email" is required and conforms to E-mail format.
Class= "url" validates to url format
Minlength= "2" is the minimum length is 2
These are all the contents of the article "how to implement jQuery plug-in Validation form validation". Thank you for reading! I believe you will gain a lot after reading this article. The editor will update different knowledge for you every day. If you want to learn more knowledge, please pay attention to the industry information channel.