JQuery Validate verification, validation rules written in a specific instance in the control
This article mainly describes the validation of jQuery Validate and the specific examples of verification rules written in the control. If you need it, you can refer to it for help.
Write the validation rule to the control.
The Code is as follows:
<Script src = "../js/jquery. js" type = "text/javascript"> </script>
<Script src = "../js/jquery. validate. js" type = "text/javascript"> </script>
<Script src = "./js/jquery. metadata. js" type = "text/javascript"> </script>
$ (). Ready (function (){
$ ("# SignupForm"). validate ();
});
<Form id = "signupForm" method = "get" action = "">
<P>
<Label for = "firstname"> Firstname </label>
<Input id = "firstname" name = "firstname" class = "required"/>
</P>
<P>
<Label for = "email"> email </label>
<Input id = "email" name = "email" class = "required email"/>
</P>
<P>
<Label for = "password"> Password </label>
<Input id = "password" name = "password" type = "password" class = "{required: true, minlength: 5}"/>
</P>
<P>
<Label for = "confirm_password"> Confirm Password </label>
<Input id = "confirm_password" name = "confirm_password" type = "password" class = "{required: true, minlength: 5, failed to: '# password'}"/>
</P>
<P>
<Input class = "submit" type = "submit" value = "Submit"/>
</P>
</Form>
Tips:
To use class = "{}", you must introduce the package: jquery. metadata. js.
You can use the following method to modify the prompt content:
Class = "{required: true, minlength: 5, messages: {required: 'Enter the content '}}"
When using the sort to keyword, the following content must be enclosed in quotation marks, as shown in the following code:
Class = "{required: true, minlength: 5, failed to: '# password '}"