This is just learned, I think it is very useful in the future, I want to share their learning.
Validation rules:
(1) Required:true must lose field (2) Number: True must enter a valid number (negative, fractional) (3) digits:trueYou must enter an integer (4) url:trueYou must enter a URL in the correct format (5) Email:trueYou must enter an email in the correct format (6) Creditcard:true must enter a valid credit card number (7) Equalto:"#password"The input value must be the same as #password (8) MaxLength:5The input length is up to5String (Chinese characters are counted as one character) (9) MinLength:TenMinimum input length isTenString (Chinese characters are counted as one character) (Ten) rangelength:[5,Ten] The input length must be between5AndTenThe string between") (Chinese characters are counted as one character)( One)Max:5Input value cannot be greater than5( A)min:TenThe input value cannot be less thanTen( -)Range:[5,Ten] Input value must be between5AndTenBetween -) AccepT:Enter a string with a valid suffix name (the suffix of the upload file) ( theDate:true must enter the correct format of the date, date check IE6 error, use caution ( -Dateiso:true must enter the correct format for the date (ISO), for example: the- .- at,1998/ on/ AValidates the format only, does not validate the validity ( -) Remote:"remote-valid.jsp"Validating input values using the Ajax method call remote-valid.jsp
1. Introduce the jquery plugin and introduce the validation plugin
2. Write a form form
3. Write jquery
<Scripttype= "Text/javascript"> $(function(){ $('#demoForm'). Validate ({rules:{//must fill inusername:{//must fill inRequired:true, //Minimum length is 6 bitsMinlenght:6, //Maximum length is 9 bitsmaxlength:9}, password:{//must fill inRequired:true, //Minimum length is 6 bitsMinlenght:6, //Maximum length is 9 bitsmaxlength: -}, age:{//minimum of 18 years oldmin: -, //maximum age is 30Max: -, //must fill in an integerdigits:true,}}, messages:{//change the content of the hint //Error Hintsusername:{Required:'This entry is required', Minlenght:'Minimum 6 guests', MaxLength:'up to 9 guests'}, password:{required:'This entry is required', Minlenght:'minimum 6-bit password', MaxLength:'password up to 16 bits'}, age:{min:'minimum 18 years', Max:'Max 80 Years'digits:'age must be a positive integer', } } }) }) </Script>
I have learned so much, and so on to learn the new one to share, thank you!!!
<script type= "Text/javascript" >$ (function () {$ (' #demoForm '). Validate ({rules:{//must be filled in username:{//required required: true,//Minimum length is 6 bits minlenght:6,//maximum length is 9 bit maxlength:9},password:{//required required:true,//Minimum length is 6 bits minlenght:6,// The maximum length is 9-bit maxlength:16},age:{//min is 18 years old min:18,//Max is 30 years old max:30,//must fill in integer digits:true,}},messages:{//change the contents of the hint// Error username:{required: ' This entry is required ', Minlenght: ' Minimum 6 bits ', maxlength: ' Up to 9 bits '},password:{required: ' This entry is required ', Minlenght: ' Password minimum 6 ', MaxLength: ' Password up to 16 bits '},age:{min: ' Minimum 18 years old ', Max: ' Max 80 years old ' digits: ' age must be a positive integer ',}}}) </script>
jquery validation Form Validation plugin.