Home >Web Front-end >JS Tutorial >jQuery form validation plug-in formValidation implements personalized error prompts_javascript skills

jQuery form validation plug-in formValidation implements personalized error prompts_javascript skills

WBOY
WBOYOriginal
2016-05-16 18:51:011533browse

The rendering is as follows:
jQuery表单验证插件formValidation实现个性化错误提示
Instructions for use
You need to use the jQuery library file and formValidation library file [Download the example code]
http://jquery.com/
At the same time, you need to customize the CSS style that displays the error message

Usage example
1, including the file part

Copy code The code is as follows:

< script src="jquery.validationEngine.js" type="text/javascript"> > The code is as follows:


The form validation method of the formValidation plug-in is as follows:
validate[required,custom[onlyLetter],length[0,100]] Parameter description: required means that the form is required, custom[] means the verification condition, and length means LengthOther instructions for the formValidation plug-in: optional: Special: When the form value is not emptyrequired: Requiredlength[0,100]: length rangeminCheckbox[7] : Minimum number of checkboxes
confirm[fieldID]: Match other fields (such as: confirm password)
telephone: Match phone number rules
email: Match email rules
onlyNumber: Match number rules
noSpecialCaracters: matching character rules
onlyLetter: matching letter rules
date: matching YYYY-MM-DD format


formValidation plug-in application example
1. Validation radio button





Copy code


The code is as follows:

< ;input class="validate[required] radio" type="radio" name="radiogoupe" value="9"/>

Second, validation check box Copy code

The code is as follows:


Three, Validate drop-down box
Copy code


The code is as follows:



Four, verification Phone numberCopy code

The code is as follows:


Five, verification email Copy code

The code is as follows:


As shown in the above example, it is relatively simple to use the formValidation plug-in to implement the form verification method, mainly because of the personalized error prompts it implements. At the same time, the matching rules can be customized, as follows:

"telephone":{ "regex" :"/^[0-9-()] $/", "alertText":"* Invalid phone number"}, where regex represents the matching rule

so that you can use alertText to implement customized form errors Prompt text, this is the same as the use of the Validation plug-in. It is recommended to use the jQuery form validation plug-in formValidation to implement personalized error prompts.
File package download
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Previous article:javascript variable scope code analysis_javascript skillsNext article:javascript variable scope code analysis_javascript skills

Related articles

See more