Recently when the project encountered a validate plug-in under IE8 Click the Submit button did not perform a check of the bugIn Chrome and FF, there are more than IE9. Baidu has a lot of articles have not found a solution, after their own test to find the problem.Click the Input type=submit button below the IE8 to not trigger the detection. A different way to do it.// compatible with IE8 notation;$ (' #login-btn '). Click (function() { $ (' #loginF
1. Introduction of js,css:http://plugins.jquery.com/validate/ 2. Set the validation rule: the class of input adds the following properties 3. Set a message that does not conform to the rule: Add data-msg-xxx (XXX is the following attribute)
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 d
The preceding example shows that the self-contained verification method in validate is sufficient to meet General requirements. For special requirements, you can use addmethod (name, method, message) to add custom verification rules, the following example adds an extension Verification Method for regular expression verification. The example is as follows:
Script Type
=
"
Text/JavaScript
"
>
Jque
Site backstage with the jquery validate framework, the version is jquery Validation Plugin 1.8.1Because it took a long time, the new version has not been updated.Recently the Company Information entry staff have adjusted, no IE11 browser, using IE8 error, error location as follows:No. 688 Line error: name is null.Find a lot of information, finally find the right
(message)? Message (value): message;validator.invalid[element.name] = true;validator.showerrors (errors);} Previous.valid = valid;validator.stoprequest (element, valid);}, param)); return "Pending";}The third step: remote setup on the front end, the request address of the background pass pastFourth step: Receive parameters in the background processing, return the corresponding processing information, note that normal time to return true, the test does not pass when the error message is returned
The verification methods of radio, checkbox, and select are not much different from those mentioned above, but the problem is that the error message is displayed after the first element in the same group. The effect is as follows:
The solution to this problem is to specify the error information to a specific location. The parameters of the validate () method can be customized. The sample code is as follows:
View code
Script Type
=
"
) {The Var reg =/^[a-za-z][a-za-z0-9]{5,14}$/;//has alphanumeric characters and the first character is a letter with a length of 6-15 bitsReturn Value.match (reg) ==null?false:true;}, "This is the user name consisting of consiste default prompt error message");JQuery.validator.addMethod ("Password_consist", function (value, Element) {The Var reg =/^[a-za-z0-9]{6,20}$/;//has alphanumeric characters and the first character is a letter with a length of 6-20Return Value.match (reg) ==null?false:true
$ (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.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 ()) {....}
$ (#form). Validate is not a function problem
The page has already be
", {required:true, min:0,messages:{min: "Please select the type of cooperation"}}); $("#realname"). Rules ("Add", {required:true}); $("#tel"). Rules ("Add", {required:true, mobile:0}); $("#shopname"). Rules ("Add", {required:true}); }And then for what reason the above elements need to be verifiedYou can delete a rulevar remove_user_validate=function() { console.info ("remove_user_validate"); $ ("#province"). Rules ("Remove"); $ ("#city"). Rules ("Remove"); $ ("#area")
There are several error conditions that can occur when authenticating a user name remotely:1. Illegal user name characters;2. length exceeding limit;3. User name already exists;However, the contents of remote can only be boolean, that is, using Datafilter to filter and do not know how to correspond to the error message also displayed.Here is a try code, but the effect of the hint is not good,Datafilter:function (data) {var json = json.parse (data);var result = new Object ();if (json.status) {$ (
Recently the company's projects are used in the jquery validate in the form, feel really very useful, very flexible, very handy. But also encountered a lot of problems. Record it here.
Problem: When submitting a form trigger check, the results of the remote check rule cannot be returned in time, resulting in a validation pass.
Scene:
In the modification page of the organization management, the teller is re
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 and success style
em {font-weight:bo
On the project registration page, you need to determine whether the user name exists. This method is implemented using the remote method of the jquery verification framework.1. js script:
Jquery. validator. addmethod ("usename", function (value, element ){
Return this. Optional (element) | value. length> = 4
Value. Length /I. Test (value) ;}, "the user name should contain 4-12 numbers and letters ");
$
this form first. Very simple. Just please note that I just gave each table item the Name property, no id attribute. The following jquery script is entirely based on name.Third, jquery script1, the entire script at the beginning, after getting the form form, first remove all the values in the form by the Serialize () method, the return value of the Serialize () method is a string to get the way to commit, y
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.