The previous section introduced two jquery plug-ins that implement Form Verification in [jquery valivalivalivalivalivali valivalivalivalivalivalivalivalivalivalivali, here we will introduce another form verification plug-in formvalidation. The biggest difference between this plug-in and the previous two plug-ins is that it implements personalized error message, which is displayed in the upper-right corner of the form Element similar to the prompt bar, which is as follows:
Instructions for use
You need to use the jquery library file and the formvalidation library file [download the instance Code]
Http://jquery.com/
At the same time, you need to customize the CSS style for displaying the error message.
Use instance
1. Contains the file section
- <SCRIPT src = "jquery. js" type = "text/JavaScript"> </SCRIPT>
- <SCRIPT src = "jquery. validationengine. js" type = "text/JavaScript"> </SCRIPT>
- <LINK rel = "stylesheet" href = "validationengine.jquery.css" type = "text/CSS" Media = "screen"/>
Ii. html Section
- <Input class ="Validate [required, custom [onlyletter], length [0,100]"Name =" firstname "type =" text "/>
The Form Verification Method of the formvalidation plug-in is as follows:
- Validate[Required, custom [onlyletter], length [0,100]
Parameter description: Required indicates that the form is required, custom [] indicates the verification condition, and length indicates the length.
Other descriptions of the formvalidation plug-in:
Optional: Special: case where the form value is not empty
Required: Required
Length [0,100]: length range
Mincheckbox [7]: Minimum number of check boxes
Confirm [fieldid]: match other fields (for example, Confirm Password)
Telephone: matching telephone number rules
Email: matching email rules
Onlynumber: number matching rule
Nospecialcaracters: Match character rules
Onlyletter: matching letter rules
Date: Match YYYY-MM-DD format
Formvalidation plug-in application instance
1. Verify the ticket token
- <Input class ="Validate[Required] Radio "type =" radio "name =" radiogoupe "value =" 5 ">
- <Input class ="Validate[Required] Radio "type =" radio "name =" radiogoupe "value =" 3 "/>
- <Input class ="Validate[Required] Radio "type =" radio "name =" radiogoupe "value =" 9 "/>
2. Check box for verification
- <Input class ="Validate[Mincheckbox [2] checkbox "type =" checkbox "name =" checkboxgroupe "value =" 5 ">
- <Input class ="Validate[Mincheckbox [2] checkbox "type =" checkbox "name =" checkboxgroupe "value =" 3 "/>
- <Input class ="Validate[Mincheckbox [2] checkbox "type =" checkbox "name =" checkboxgroupe "value =" 9 "/>
3. Verify the drop-down list
- <Select name = "sport" id = "sport" class ="Validate[Required] ">
- <Option value = "1"> biuuu_1 </option>
- <Option value = "2"> biuuu_2 </option>
- <Option value = "3"> biuu_3 </option>
- <Option value = "4"> biuuu_4 </option>
- </SELECT>
4. Verify the phone number
- <Input class = "Validate [required, custom [Telephone] Text-input" type = "text" name = "telephone"/>
5. verify email
- <Input class = "Validate [required, custom [email] Text-input" type = "text" name = "email" id = "email"/>
For the above example, it is relatively simple to use the formvalidation plug-in to implement form verification, mainly because of its personalized error prompts and custom matching rules, as shown below:
- "Telephone ":{
- "RegEx":"/^ [0-()] + $ /",
- "Alerttext":" * Invalid phone number "},
RegEx indicates matching rules.
In this way, alerttext can be used to implement custom form error prompt text, which is the same as the method used by the validation plug-in. It is recommended to use the jquery Form Verification plug-in formvalidation to implement personalized error prompts.
Click here to download the jquery plug-in formvalidation instanceSource code
Http://jquerycodes.googlecode.com/files/formValidator.zip
RelatedArticle
Jquery valivalivalivalivali JavaScript form verification function
Jquery plugin validation form to implement smart JavaScript Form Verification
If the original article is reprinted, please note: Reprinted from the blog Http://www.biuuu.com/
Link: http://www.biuuu.com /? P = 1104