Here are some of the more commonly used regular expressions I've collected, because it's usually possible to use more of the form validation. Special sends out, lets each friend use together.
ID Card Verification
JQuery.validator.addMethod ("Isidcard", function (value, element, type) {
if ($ (type). val () = = ' 1 ') {
var re =/(^ /d{15}$) | (^/d{18}$) | (^/d{17} (/d| X|X) $)/;
return this.optional (Element) | | (Re.test (value));
} else {return
true;
}
}, "Incorrect ID card format");
Passport Verification
JQuery.validator.addMethod ("Ispassport", function (value, element, type) {
if ($ (type). val () = = ' 2 ') {
var Re1 =/^[a-za-z]{5,17}$/;
var re2 =/^[a-za-z0-9]{5,17}$/;
return this.optional (Element) | | (Re2.test (value)) | | Re1.test (value);
} else {return
true;
}
}, "Passport format is not correct");
Hong Kong and Macao Pass verification
JQuery.validator.addMethod ("Ishkmacao", function (value, element, type) {
if ($ (type). val () = = ' 3 ') {
var re =/^ [HMHM] {1} ([0-9]{10}| [0-9] {8}) $/;
return this.optional (Element) | | (Re.test (value));
} else {return
true;
}
}, "Hong Kong and Macao Pass format is not correct");
Taiwan Pass Verification
JQuery.validator.addMethod ("Istaiwan", function (value, element, type) {
if ($ (type). val () = = "4") {
var Re1 =/ ^[0-9]{8}$/;
var re2 =/^[0-9]{10}$/;
return this.optional (Element) | | (Re1.test (value)) | | (Re2.test (value))
} else {return
true;
}
}, "Taiwan Pass format is not correct");
The above content is small series to introduce more commonly used documents regular expression verification encyclopedia, I hope you like.