Mobile phone number Verification
The following are reference content:
Copy Code code as follows:
JQuery.validator.addMethod ("mobile", function (value, Element) {
var length = Value.length;
var mobile =/^ ((13[0-9]{1}) | ( 15[0-9]{1}) +\d{8}) $/
return this.optional (Element) | | (length = = && Mobile.test (value));
}, "mobile phone number format error");
Phone number Verification
The following are reference content:
Copy Code code as follows:
JQuery.validator.addMethod ("Phone", function (value, Element) {
var tel =/^ (0[0-9]{2,3}\-)? ([2-9][0-9]{6,7}) + (\-[0-9]{1,4})? $/;
return this.optional (Element) | | (Tel.test (value));
}, "Phone number format error");
zip code verification
The following are reference content:
Copy Code code as follows:
JQuery.validator.addMethod ("ZipCode", function (value, Element) {
var tel =/^[0-9]{6}$/;
return this.optional (Element) | | (Tel.test (value));
}, "ZIP code format error");
QQ Number Verification
The following are reference content:
Copy Code code as follows:
JQuery.validator.addMethod ("QQ", function (value, Element) {
var tel =/^[1-9]\d{4,9}$/;
return this.optional (Element) | | (Tel.test (value));
}, "QQ number format error");
IP Address Verification
The following are reference content:
Copy Code code as follows:
JQuery.validator.addMethod ("IP", function (value, Element) {
var ip =/^ (?:(? : 25[0-5]|2[0-4][0-9]| [01]? [0-9] [0-9]?) \.) {3} (?: 25[0-5]|2[0-4][0-9]| [01]? [0-9] [0-9]?) $/;
return this.optional (Element) | | (Ip.test (value) && (Regexp.$1 < 256 && regexp.$2 < 256 && regexp.$3 < 256 && Rege Xp.$4 < 256));
}, "IP address format error");
verification of letters and numbers
The following are reference content:
Copy Code code as follows:
JQuery.validator.addMethod ("Chrnum", function (value, Element) {
var chrnum =/^ ([a-za-z0-9]+) $/;
return this.optional (Element) | | (Chrnum.test (value));
"Only numbers and letters (characters A-Z, A-Z, 0-9)" can be entered;
Verification in Chinese
The following are reference content:
Copy Code code as follows:
JQuery.validator.addMethod ("Chinese", function (value, Element) {
var Chinese =/^[\u4e00-\u9fa5]+$/;
return this.optional (Element) | | (Chinese.test (value));
"Can only be entered in Chinese");
Dropdown Box Validation
The following are reference content:
Copy Code code as follows:
$.validator.addmethod ("Selectnone", function (value, Element) {
return value = = "Please select";
"Must select an item");
byte length validation
The following are reference content:
Copy Code code as follows:
JQuery.validator.addMethod ("Byterangelength", function (value, element, param) {
var length = Value.length;
for (var i = 0; i < value.length; i++) {
if (Value.charcodeat (i) > 127) {
length++;
}
}
return this.optional (Element) | | (length >= param[0] && length <= param[1]);
},$.validator.format ("Make sure the value entered is between {0}-{1} bytes (2 bytes in one)");