jquery Validation Framework :
Basic HTML Code:
1<script src="Js/jquery-1.9.1.js"></script>2<script src="Js/jquery.validate.min.js"></script>3<script>4 $ (function () {5$('#myForm'). Validate ({6 7 Rules: {8 //User name9username: {//refers to the name in inputTenRequiredtrue, oneRangelength: [6, one] a }, - //Password - password: { theRequiredtrue, -Rangelength: [ one, a] - }, - }, + - Messages: { + //User name a username: { atRequired'This entry is required', -Rangelength:'user name is 6-11 bits long' - }, - //Password - password: { -Required'This entry is required', inRangelength:'user name is 11-12 bits long' - }, to }, + //Verify all through - submithandler:function () { theAlert"Check All through! ") * }, $ Panax Notoginseng }) - }) the</script> + a html: +<form action=""Id="MyForm"> -<!--user name-- $<p> $<label for="User">username:</label> -<input type="text"Name="username"Id="User"/> -</p> the<!--password-- -<p>Wuyi<label for="Pass">password:</label> the<input type="text"Name="Password"Id="Pass"/> -</p> wu<!--submit- -<p><input type="Submit"Value="Submit"/></p> about</form>
From the above code I say the use of jquery Validation.
1.validate (options) is the start of running form form, He is used to verify the form you selected, the fifth line of the above code "#myForm" is the ID name of the FORM.
2.rules () is a validation rule he's the Validate. the user-defined key/value pair rule = = key is the Name property of a form element, the value is a simple string, or an object consisting of a rule/parameter pair.
3. Messages () is a user-defined key/value pair message = = = Key is the Name property of a form element, and the value is the message that the form element will Display.
The username and password in 4.rules () are the name values in Input.
A value of 5.required is true when verifying that the item is a required Option.
6.minlength (length) Sets the minimum length of the validation element.
7.maxlength (length) Sets the maximum length of the validation element.
8.rangelength (range) sets a length range for the validation element.
9.max (value) Sets the maximum value of the validation element.
10.min (value) Sets the minimum value of the validation element.
The 11.range () setting refers to the Range.
12.email () Verify that the e-mail format is Correct.
13.url () Verify that the URL format is Correct.
14.date () Verify that the date format is Correct. "note: do not verify the accuracy of the date, only verify the format "
15.submitHandler when the form is validated, submit the Form.
// Verify all through submithandler:function () { alert (" Verify all Passes!") ") },
invalidhandler .when aform that is not validated is submitted, you can handle something in the callback Function.
// Check does not pass invalidhandler:function () { alert ("no") },
Focusinvalid The default value is true, when the checksum fails, the focus jumps to the first invalid form Element.
focuscleanup The default value is true, when the form has the focus, remove the Errorclass on the form and hide all error messages. note: Avoid using with FOCUSINVALID. "
Errorelement creates a container for error messages with HTML element types. The default is written in the label
errorclass style to define the error Message.
Highlight sets the highlighting of form elements that are not validated.
Highlight:function (element, errorclass) { $ (element). addclass (errorclass); $ (element). Fadeout.fadein (); }
These are my contacts, and there are many more about the jquery validation Framework . Interested can check the API of JQuery.validate.js.
Form verification of Jquery.validate