JQuery Validate verification, validation rules written in a specific instance in the control

Source: Internet
Author: User

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 '}"

 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.