Jquery Form Verification plug-in formvalidation for personalized error messages

Source: Internet
Author: User

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

    1. <SCRIPT src = "jquery. js" type = "text/JavaScript"> </SCRIPT>
    2. <SCRIPT src = "jquery. validationengine. js" type = "text/JavaScript"> </SCRIPT>
    3. <LINK rel = "stylesheet" href = "validationengine.jquery.css" type = "text/CSS" Media = "screen"/>

Ii. html Section

    1. <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:

    1. 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

    1. <Input class ="Validate[Required] Radio "type =" radio "name =" radiogoupe "value =" 5 ">
    2. <Input class ="Validate[Required] Radio "type =" radio "name =" radiogoupe "value =" 3 "/>
    3. <Input class ="Validate[Required] Radio "type =" radio "name =" radiogoupe "value =" 9 "/>

2. Check box for verification

    1. <Input class ="Validate[Mincheckbox [2] checkbox "type =" checkbox "name =" checkboxgroupe "value =" 5 ">
    2. <Input class ="Validate[Mincheckbox [2] checkbox "type =" checkbox "name =" checkboxgroupe "value =" 3 "/>
    3. <Input class ="Validate[Mincheckbox [2] checkbox "type =" checkbox "name =" checkboxgroupe "value =" 9 "/>

3. Verify the drop-down list

    1. <Select name = "sport" id = "sport" class ="Validate[Required] ">
    2. <Option value = "1"> biuuu_1 </option>
    3. <Option value = "2"> biuuu_2 </option>
    4. <Option value = "3"> biuu_3 </option>
    5. <Option value = "4"> biuuu_4 </option>
    6. </SELECT>

4. Verify the phone number

    1. <Input class = "Validate [required, custom [Telephone] Text-input" type = "text" name = "telephone"/>

5. verify email

    1. <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:

    1. "Telephone ":{
    2. "RegEx":"/^ [0-()] + $ /",
    3. "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

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.