Jquery Validate
I. What is jquery Validate:
The JQuery Validate plugin provides a powerful validation feature for your form.
Two. Common values:
1 |
Required:true |
The field that must be entered. |
2 |
Remote: "check.php" |
Use the Ajax method to call check.php to validate the input values. |
3 |
Email:true |
You must enter an e-mail message in the correct format. |
4 |
Url:true |
You must enter a URL in the correct format. |
5 |
Date:true |
You must enter a date in the correct format. Date Check IE6 error, use with caution. |
6 |
Dateiso:true |
You must enter the correct format for the date (ISO), for example: 2009-06-23, 1998/01/22. Verify the format only and do not validate the validity. |
7 |
Number:true |
You must enter a valid number (negative, fractional). |
8 |
Digits:true |
You must enter an integer. |
9 |
CreditCard |
You must enter a valid credit card number. |
10 |
Equalto: "#field" |
The input value must be the same as #field. |
11 |
Accept |
Enter a string with a valid suffix name (the suffix of the upload file). |
12 |
Maxlength:5 |
Enter a string with a maximum length of 5 (Chinese characters are counted as one character). |
13 |
Minlength:10 |
Enter a string with a minimum length of 10 (Chinese characters are counted as one character). |
14 |
RANGELENGTH:[5,10] |
Enter a string that must be between 5 and 10 (Chinese characters are counted as one character). |
15 |
RANGE:[5,10] |
The input value must be between 5 and 10. |
16 |
Max:5 |
The input value cannot be greater than 5. |
17 |
Min:10 |
The input value cannot be less than 10. |
Three. Demo:
Html:
<Body> <Div> <formID= "Form1"Action="/"Method= "POST"> <inputtype= "text"name= "Name" /><BR/> <inputID= "PWD"type= "text"name= "PWD" /><BR/> <inputtype= "text"name= "PWD_OK" /><BR/> <inputtype= "text"name= "Email" /><BR/> <inputtype= "text"name= "Address" /><BR/> <inputtype= "text"name= "Age" /><BR/> <inputtype= "Submit"value= "Submit" /> </form> </Div></Body>
Js:
<script type= "Text/javascript" > $(function () { $("#form1"). Validate ({rules: {Name: {required:true}, Email: {required:true, Email:true}, PWD: {required:true, digits:true, rangelength: [5, 10]}, PWD_OK: {required:true, digits:true, rangelength: [5, 10], Equalto:"#Pwd"}}, messages: {Name: {R Equired:"* Please enter a name"}, Email: {required:"* Mailbox cannot be empty", Email:"* Mailbox format is incorrect" } } }) }); </script>
Four. Download:
Novice Tutorials Provide CDN:
Http://static.runoob.com/download/jquery-validation-1.14.0.zip
If you are using the Visual Studio IDE, you can download it directly using the NuGet tool;
jquery Plugins jquery Validate