, we often encounter the need for group verification.
This verification control of Microsoft is very good. In Microsoft's controls, it is available by default.ValidationgroupIf you set the attribute name to the same name, you can perform group verification. However, jquery. Validate itself does not provide this function, so we can only expand it by ourselves.
For specific scenarios, there are two tab pa
This article mainly introduces you in detail based on Bootstrap + jQuery. validate is used to implement form verification. If you are interested, you can refer to this practice. The services that you first came into contact with at the front-end are user registration and login. Now the society adheres to the people-oriented philosophy, as is the case in the websi
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.
Overview: This article mainly discusses jquery.validate combined with Jquery.form to implement the verification and submission scheme of the form.
Mode one: It is through the jquery.validate submithandler option, that is, the callback function is executed when the form is validated. Submits the form through Jquery.form in this callback function;
Mode two: It is
If you need to modify these hints, you can add any information prompts that you want to display in the JS code.We use the most common forms of registration verification as an example to illustrate:First, you have a form, and you define the ID of the form.
Then introduce the following four JS files:
Then customize a JS file, the contents of this JS file are as follows:$ ("#login").
.
Creditcard:true
You must enter a valid credit card number
Equalto: "#field"
The input value must be the same as #field
Accept
Enter a string with a valid suffix name (the suffix of the upload file).
Maxlength:5
Enter a string with a maximum length of 5 (Chinese characters are counted as one character).
Minlength:10
Enter a string with a minimum length of 10 (Chinese characters are counted as one char
, validating code
because there is no mobile authentication in the jquery.validate.js, you need to add a first to find messages in the box below:
messages: {required: "This field are required.", Remote: "Please fix this field.", E Mail: "Please enter an valid email address.", url: ' Please enter a valid URL. ', Date: "Please enter a valid date.", D Ateiso: "Please enter a valid date (ISO).", Number: "To enter a valid.", Mobile: "Fill in the correct cell phone numbe
$ ("#commentForm"). Validate (): On it, what parameters should be added ...
Registration information authentication text message $ (function () {JQuery.validator.addMethod ("IsMobile", function (value, Element) {var length = Val
Ue.length; return this.optional (Element) | | (length = /^ ((13[0-9]{1}) | ( 15[0-9]{1}) | (18[0-9]{1}))
+\D{8}) $/.test (value)); "Please fill in your phone number correctly."
"); Entry into force $ ("#signup
This article introduces the jquery validate form verification, sharing for everyone's reference, the specific contents are as follows
One, add a different plug-in jquery.validate.messages_cn.js.Change the default prompt.
* * Translated default messages for the JQuery validation plugin.
* LANGUAGE:CN
* auth
This article illustrates the jquery Validate form verification plug-in, how to customize a validation method, share for everyone to refer to, the specific content as follows
The effect is as follows:
Validation failure Effect:
To verify successful results:
Specific steps:
1, the introduction of the dependency package
2, add error style
Jquery.validate.min.js is a powerful jquery form verification feature that many people mistakenly assume only when submitting a form can trigger validation. In fact, the same can be triggered by JS. The code is as follows:
$ ("#myform"). Validate ({....})
if ($ ("#myform"). Valid ()) {....}
$ (#
Let me explain the keywords and meanings of the validation form. JQuery. validate comes with: required: "required field", remote: "correct this field", email: "enter an email in the correct format", url: "enter a valid URL", date: "enter a valid date", dateISO: "enter a valid date (ISO ). ", number:" enter a valid number ", digits:" Only an integer can be entered
$ (function () {var method= ' ${method} ';if (method = = ' edit ') {Url= "${ctx}/commodity/typerename.json";}else{Url= "${ctx}/commodity/typeadd.json";}$ ("#commodityTypeForm"). Validate ({onsubmit:true,//whether the commit is a validationonfocusout:false,//whether to validate when the focus is acquiredonkeyup:false,//whether to verify when tapping the keyboardRules: {typename:{Required:true,byterangelength
Jquery. validate verification form. submit data in your own js and return json$. Metadata. setType ("attr", "vld"); $. validator. addMethod ("username", function (value) {var p =/^ [0-9a-zA-Z \ u4e00-\ u9fa5 \. \-@ _] + $/; return p.exe c (value )? True: false;}, "Please enter only letters, digits, chinese and '_', '-', '@'"); $. metadata. setType ("attr", "vld")
Jquery validate is verified, but chrome cannot be submitted. Later, I found "a problem encountered when jquery. validation was applied to the ASP. NET project" on the Internet"
The solution is as follows:
Your Asp.net submit button
Chrome may not recognize the name value generated by this Asp.net button. jquery
1. Usage overview and important usage in Jquery. Validate 1. Common forms are combined with Jquery. Validate verification methods to verify the user name, age, and zip code. Copy the following code in the html form: 1
One, download the dependency packageNET disk Download: Https://yunpan.cn/cryvgGGAQ3DSW access password f224Second, add a separate plugin jquery.validate.messages_cn. js.Change the default prompt mode.Third, jquery form validation plug-in----by the Name property to correlate fields to verify that Officer rules are written into the JS code. for= "Cusername" > Name for= "Cemail" > Email for= "curl" > URL fo
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.