// Mobile phone number verification
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 = 11 & mobile. Test (value ));
}, "Incorrect Mobile Phone Number Format ");
// Phone number verification
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 ));
}, "Incorrect Phone Number Format ");
// Postal code verification
Jquery. validator. addmethod ("zipcode", function (value, element ){
VaR Tel =/^ [0-9] {6} $ /;
Return this. Optional (element) | (Tel. Test (value ));
}, "Incorrect zip code format ");
// QQ number verification
Jquery. validator. addmethod ("QQ", function (value, element ){
VaR Tel =/^ [1-9] \ D {4, 9} $ /;
Return this. Optional (element) | (Tel. Test (value ));
}, "Incorrect QQ number format ");
// Ip address verification
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 & Regexp. $4 <256 ));
}, "Ip address format error ");
// Letter and number verification
Jquery. validator. addmethod ("chrnum", function (value, element ){
VaR chrnum =/^ ([a-zA-Z0-9] +) $ /;
Return this. Optional (element) | (chrnum. Test (value ));
}, "Only numbers and letters (character A-Z, A-Z, 0-9 )");
// Chinese Verification
Jquery. validator. addmethod ("Chinese", function (value, element ){
VaR Chinese =/^ [\ u4e00-\ u9fa5] + $ /;
Return this. Optional (element) | (Chinese. Test (value ));
}, "Only Chinese characters can be entered ");
// Drop-down box Verification
$. Validator. addmethod ("selectnone", function (value, element ){
Return Value = "select ";
}, "Must be selected ");
// Bytes length Verification
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 that the input value is between {0}-{1} bytes (two bytes for one text )"));