jquery validation js files. Then add class to two input:
And
Then, in the read event of document, add the following method:
So, when a form is submitted, it is validated against the class specified by input. If it fails, the form's submission is blocked. Also, the prompt is displayed after the input.
Introduction to JQuery Validate Plug-ins
The JQuery Validate plug-in provides a powerful validation feature for forms, making client form validation simpler, while providing a wide range of customization options to meet the needs of the application. The plug-in bundles a set of useful authentication methods, including
true or false Based on | the purpose of the subsequent verification. In summary, this. optional (element) is used to indicate that the field currently verified is not required.
The third parameter is as follows:
Copy codeThe Code is as follows:$. Validator. format ("cannot exceed {0} bytes (one text is counted as two bytes )")
The third parameter can be a message that indicates the verification prompt. to display the function verification information, you can also create the function
The JQuery Validate plug-in provides a powerful validation feature for forms, making client form validation simpler, while providing a wide range of customization options to meet the needs of the application. The plug-in bundles a set of useful authentication methods, including URL and email authentication, while providing an API for writing user-defined methods.
Defining Chinese messagesvar cnmsg = {Required: "Required field",Remote: "Please fix this field",Email: "Please enter the correct format of e-mail",URL: "Please enter a valid URL",Date: "Please enter a valid date",Dateiso: "Please enter a valid date (ISO).",Number: "Please enter a valid digit",Digits: "Can only enter integers",CreditCard: "Please enter a valid credit card number",Equalto: "Please enter the same value again",Accept: "Please enter a str
combination. You can use method two to save a more general template, and then use the method to customize the prompts as specified.
The above is what I learned this afternoon of the harvest. It is said that in the new version, there is a new writing, neither need to rely on the Jquery.metadata.js library mentioned above, nor need to customize the hint information through JavaScript, but in the label to data-rule-validation rules, data-msg-hint information This format is redefined. Eager......
The most common use of JavaScript is the validation of forms, and jquery, as a good JavaScript library, also provides an excellent form validation plug-in----Validation. Validation is one of the oldest jquery Plug-ins and has been validated by a wide variety of projects worldwide, and has been praised by many web developers. As a standard validation method library, validation has the following features:
1.
Default classification 2010-04-04 20:35:01 Read 123 Comments 0 font size: Big SmallJquery.validate is a validation framework for jquery, and with the advantage of jquery, we can quickly validate some of the common inputs and expand our own validation methods and support internationalization as well.Description: Requires jquer
decimal digits ( Include decimal) Digits:true,//verify integer Creditcard:true,//Verify credit card number Accept: "//Enter a string with a valid suffix name (the suffix of the upload file) Equalto: "ID Name"//verify that the contents of the two input boxes are the same Phoneus:true//Verify American phone numbers regex:/regular expressions///validation rules for Addmethod extensions above } } messages:{Name: "Name cannot be empty",//
methodMinLength (length)Back: BooleanSet Minimum Length MaxLength (length)Back: BooleanSet Maximum lengthRangelength (Range)Back: BooleanSet a length range [Min,max]Min (value)Back: BooleanSet maximum valueMax (value)Back: BooleanSet minimum valueEmail ()Back: BooleanVerify e-mail formatRange (range)Back: BooleanSet the range of valuesURL ()Back: BooleanValidate URL formatDate ()Back: BooleanValidate date format (similar to 30/30/2008 format, do not validat
Official Use document: http://jqueryvalidation.org/documentation/Reference: http://www.w3cschool.cc/jquery/jquery-plugin-validate.htmlImport JS files remember to use compressed. Min JS relies on jquery version in 1.11.1 No problem other versions are not tested The HTML structure is made using the thinkphp framework. How to use:The most basic is the form ID t
passedUsername: function (){Return $ ("# username"). val ();}}}
The remote address can only output "true" or "false", but cannot output other parameters.
9 add custom VerificationAddMethod: name, method, messageCustom Verification Method
The Code is as follows:
// Two Chinese charactersJQuery. validator. addMethod ("byteRangeLength", function (value, element, param ){Var length = value. length;For (var I = 0; I If (value. charCodeAt (I)> 127 ){Length ++;}}Return this. optional (element) | (l
Quick Solution that JQuery. validate does not support in ie8, jquery. validateie8
I. Back the problematic code in ie8
1. The JQuery. validate verification framework verifies whether the input in the
The name attribute is consist
JQuery Validation PluginAdvantages:1. Form validation is simple and convenient, and many configuration items are available2. Internationalization, you can customize the prompt informationCommand-line InstallationInitialize BowerBower InitInstalling jquery using BowerBower Install jquery--save-devInstalling the Jquery-
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.