Deep Learning about jQuery Validate form verification, jqueryvalidate

Source: Internet
Author: User
Tags api manual valid email address

Deep Learning about jQuery Validate form verification, jqueryvalidate

This article introduces jQuery Validate form verification, mainly by using jquery. metadata. js directly writes verification rules in the class attribute and defines the error message. The content is as follows:

1. Add another plug-in jquery. metadata. js and write the validation rules in the control.
2. You need to rewrite the method that triggers verification.

$("#commentForm").validate({meta: "validate"});

3. The detailed code is as follows:

<Html> 

Default verification rules:

  • (1) required: required field for true
  • (2) remote: "check. php" uses ajax to call check. php to verify the input value.
  • (3) email: true: You must enter an email in the correct format.
  • (4) url: true must enter the url in the correct format
  • (5) date: true: You must enter a date in the correct format to verify ie6. Use it with caution.
  • (6) dateISO: true: the date (ISO) in the correct format must be entered. For example, 2009-06-23,1998/01/22: only the format is verified and the validity is not verified.
  • (7) number: true: a valid number (negative number, decimal number) must be entered)
  • (8) digits: true must be an integer.
  • (9) creditcard: a valid credit card number must be entered.
  • (10) must to: "# field" the input value must be the same as # field
  • (11) accept: enter a string with a valid suffix (the suffix of the uploaded file)
  • (12) maxlength: A string with a maximum length of 5 characters)
  • (13) minlength: 10 string with a minimum input length of 10 (one character for Chinese characters)
  • (14) rangelength: [5, 10] The input length must be a string between 5 and 10. ") (a Chinese character is a single character)
  • (15) range: [5, 10] The input value must be between 5 and 10.
  • (16) max: 5 input value cannot be greater than 5
  • (17) min: 10 input value cannot be less than 10

Default prompt:

Messages: {required: "This field is required. ", remote:" Please fix this field. ", email:" Please enter a valid email address. ", url:" Please enter a valid URL. ", date:" Please enter a valid date. ", dateISO:" Please enter a valid date (ISO ). ", dateDE:" Bitte geben Sie ein g eyebrow ltiges Datum ein. ", number:" Please enter a valid number. ", numberDE:" Bitte geben Sie eine Nummer ein. ", digits:" Please enter only digits ", creditcard:" Please enter a valid credit card number. ", failed to:" Please enter the same value again. ", accept:" Please enter a value with a valid extension. ", maxlength: $. validator. format ("Please enter no more than {0} characters. "), minlength: $. validator. format ("Please enter at least {0} characters. "), rangelength: $. validator. format ("Please enter a value between {0} and {1} characters long. "), range: $. validator. format ("Please enter a value between {0} and {1 }. "), max: $. validator. format ("Please enter a value less than or equal to {0 }. "), min: $. validator. format ("Please enter a value greater than or equal to {0 }. ")},

4. as follows:

5. Note:
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. The Code is as follows:

class="{required:true,minlength:5,equalTo:'#password'}"

6. Define the error message directly in the class attribute.

<Html> 

7. The effect is as follows:

 

The above is all the content of this article. I hope it will help you learn jQuery Validate form verification. Recently I have updated many articles on jQuery Validate form verification.

Articles you may be interested in:
  • Getting started with jquery validate. js Form Verification
  • JQuery. Validate usage notes (jQuery Validation example)
  • Jquery. validate
  • Step 4 of jquery validate Introduction
  • JQuery validate Chinese API attached validate. js Chinese api Manual
  • JQuery EasyUI API Chinese Document-ValidateBox verification box
  • Usage of jQuery. Validate verification Library
  • Form Verification Based on Bootstrap + jQuery. validate

Related Article

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.