Validate Form Validation

Source: Internet
Author: User

Use validate to do form verification, the effect is as shown in figure:



Of course, can also be changed to Chinese (if you feel that the default message is not what you want, you can also customize the hint message)


Validate Use steps:
1. Import Jquery.js
2. Import Validate.js
3. Verify the form after the page has been successfully loaded $ (selector). Validate ()
4. Write validation rules in validate
$ ("selector"). Validate ({
rules:{},
messages:{}
});

4.1 Here the rules are written in the specific specifications, what constraints to do

The 4.2messages {} is written in violation of the given cue message.

### the format within #rules {}:
Format 1:
The Name property of the field: "Validator"
Format 2:
Field's Name property: {Validator: Value, Validator: Value}

Where: Format 1 is an input box when only one validator is used

and Format 2 is an input box that needs to have multiple validators when used

The format of the ### #messages {} is similar to the rules

Messages format:
Format 1:
The Name property of the field: "Hint Info"
Format 2:
Name property of the field: {validator: Prompt info, validator: Prompt Info}


--------------------------------------------------------------------------------------------------------------- --------------------------------

The specific cases are as follows:

<! DOCTYPE html>
Validator Query Table:

Checksum type

Take value

Describe

Required

True|false

Required Fields

Email

"@" or "email"

Mailing Address

Url

Path

Date

Digital

Date

Dateiso

String

Date (YYYY-MM-DD)

Number

Number (negative, decimal)

Digits

Integer

MinLength

Digital

Minimum length

MaxLength

Digital

Maximum length

Rangelength

[MINL,MAXL]

Length Range

Min

Minimum value

Max

Maximum Value

Range

[Min,max]

Value Range

Equalto

jquery expressions

Two values are the same

Remote

URL path

Ajax Checksum



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.