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 |