Deep learning jquery Validate form validation _jquery

Source: Internet
Author: User
Tags comments curl jquery form validation

This article introduces the jquery validate form verification, mainly uses the Jquery.metadata.js officers transferred Guevara rule to write directly in the class attribute and the definition error message prompt, shares for everybody to refer, the concrete content is as follows

1, add a different plug-in jquery.metadata.js and write the validation rules in the control.
2, need to rewrite the way the trigger check.

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

3, the detailed code is as follows:

 

Default checksum rule:

  • (1) Required:true must be lost field
  • (2) Remote: "check.php" use Ajax method to invoke check.php validate input value
  • (3) Email:true must enter the correct format email
  • (4) Url:true must enter the URL in the correct format
  • (5) Date:true must enter the correct format of the date and date check IE6 error, use caution
  • (6) Dateiso:true must enter the correct format of the date (ISO), for example: 2009-06-23, 1998/01/22 only verify the format, do not verify the validity
  • (7) Number:true must enter a valid number (negative, decimal)
  • (8) Digits:true must enter an integer
  • (9) CreditCard: Must enter the legal credit card number
  • (a) Equalto: "#field" input value must be the same as #field
  • (one) Accept: Enter a string with a valid suffix name (the suffix of the uploaded file)
  • (Maxlength:5) A string with a maximum of 5 input length (Chinese characters are counted as one character)
  • (Minlength:10) A string with a minimum input length of 10 (Chinese characters are counted as one character)
  • (rangelength:[5,10] Enter a string that must be between 5 and 10) (Chinese characters are counted as one character)
  • () range:[5,10] The input value must be between 5 and 10
  • () Max:5 input value cannot be greater than 5
  • (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 EMA Il address. ', url: ' Please enter a valid URL. ', Date: ' Please enter a valid date. ', Dateiso: "Please enter a valid D Ate (ISO). ", Datede:" Bitte geben Sie ein G eyebrow ltiges Datum. ", Number:" Please enter a ein number. ", Valid:" B Itte geben Sie eine Nummer ein. ", Digits:" Please enter only digits ", CreditCard:" To enter a valid credit card Nu Mber. ", Equalto:" Please enter the same value again. ", Accept:" To enter a value with a valid extension. ", Maxle Ngth: $.validator.format ("Please enter no further than {0} characters."), MinLength: $.validator.format ("Please enter at Le AST {0} characters. "), Rangelength: $.validator.format (" Please enter a value between {0} and {1} characters long. "), R Ange: $.validator.format ("Please enter a value between {0} and {1}."), Max: $.validator.format ("Please enter a value les s than or equal to {0}. "Min: $.validator.format ("Please enter a value greater than or equal to {0}.")},
 

4. The effect chart is as follows:

5. Note:
The package must be introduced in the way class= ' {} ' is used: jquery.metadata.js.
You can modify the hint by using the following methods:

Class= ' {required:true,minlength:5,messages:{required: ' Please enter the content '}} '

When using the Equalto keyword, the following must be enclosed in quotation marks, as shown in the following code:

Class= "{required:true,minlength:5,equalto: ' #password '}"

6, directly in the class attribute to define the error message hint.


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.