Regular Expression of JQueryeasyUI extension Verification Mechanism

Source: Internet
Author: User
Extended 1 $ extend ($ fnvalidateboxdefasrsrules, {verify Chinese CHS: {validator: function (value) {return ^ [u0391-uFFE5] + $ test (value) ;}, message: & quot; only Chinese Characters & quot;} can be entered. Character verification stringCheck: {vali expansion 1 $. extend ($. fn. validatebox. defaults. rules, {// verify the Chinese CHS: {validator: function (value) {return/^ [\ u0391-\ uFFE5] + $ /. test (value) ;}, message: "Only Chinese characters can be entered. "}, // character verification stringCheck: {validator: function (value) {return/^ [\ u0391-\ uFFE5 \ w] + $ /. test (value) ;}, mescript E: "Only Chinese characters, English letters, numbers, and underscores are allowed. "}, // verify Chinese, English, number stringCheckSub: {validator: function (value) {return/^ [a-zA-Z0-9 \ u4E00-\ u9FA5] + $ /. test (value) ;}, message: "can only contain Chinese characters, English letters, and numbers. "}, englishCheckSub: {validator: function (value) {return/^ [a-zA-Z0-9] + $ /. test (value) ;}, message: "Only English letters and numbers are allowed. "}, numberCheckSub: {validator: function (value) {return/^ [0-9] + $ /. test (value) ;}, message: "Only numbers can be entered. "}, // mobile phone number verification mobile: {validator: function (value) {v Ar reg =/^ (13 [0-9] {1}) | (14 [0-9] {1 }) | (15 [0-9] {1}) | (18 [0-9] {1}) + \ d {8}) $/; return value. length = 11 & reg. test (value) ;}, message: "Please enter your mobile phone number correctly. "}, // telephone number verification: {validator: function (value) {// Phone Number Format 010-12345678var reg =/^ \ d {3, 4 }? \ D {7, 8} $/; return reg. test (value) ;}, message: "Please enter your phone number correctly. "}, // call number (mobile phone number or phone number) to verify mobileTelephone: {validator: function (value) {var cmccMobile =/^ (13 [0-9] {1}) | (14 [0-9] {1 }) | (15 [0-9] {1}) | (18 [0-9] {1}) + \ d {8}) $ /; var tel =/^ \ d {3, 4 }? \ D {7, 8} $/; return tel. test (value) | (value. length = 11 & cmccMobile. test (value) ;}, message: "Please enter your contact number correctly. "}, // verify zipCode: {validator: function (value) {var reg =/^ [1-9] \ d {5} $/; return reg. test (value) ;}, message: "the zip code must be 6 digits starting with 0. "}, // ID card number verification idCardNo: {validator: function (value) {return isIdCardNo (value) ;}, message:" Please enter your ID card number correctly. "}, // verify that the two parameters are not empty at the same time. // you can customize the prompt information allNotNull: {validator: function (toValue, fromValu E) {if (fromValue = null | fromValue. length = 0 | fromValue [0] = null | fromValue [0] = "") {if (toValue = null | toValue. length = 0 | toValue [0] = null | toValue [0] = "") {$. fn. validatebox. defaults. rules. compareDigit. message = "medium, English. the text name cannot be blank at the same time "; return false;} else {return true ;}} else {return true ;}, message:" },// number verification size, the end value should be greater than the start value // you can customize the prompt information compareDigit: {validator: function (toValue, fromValue) {if (fromValue = = Null | fromValue. length = 0 | fromValue [0] = null | fromValue [0] = "") {return true;} if (parseFloat (toValue)> parseFloat (fromValue [0]) {return true;} else {if (fromValue. length> = 2) {$. fn. validatebox. defaults. rules. compareDigit. message = fromValue [1];} else {$. fn. validatebox. defaults. rules. compareDigit. message = 'end value should be greater than start value';} return false }}, message: ""}, // Date, time verification size, end date should be later than start date // you can customize the prompt information compareDate: {v Alidator: function (toDate, param) {if (param = null | param. length = 0 | param [0] = null | param [0] = "") {return true;} if (toDate> param [0]) {return true;} else {if (param. length> = 2) {$. fn. validatebox. defaults. rules. compareDate. message = param [1];} else {$. fn. validatebox. defaults. rules. compareDate. message = 'end date should be later than 'startdate';} return false }}, message: ''} // verify on the server/* remote: {validator: function (value, param) {var p Arams = {}; params [param [1] = value; $. post (param [0], params, function (data) {if (! Data. msg) {$. fn. validatebox. defaults. rules. account. message = param [2];} return data. msg;}) ;}, message: "} */}) // -- ID card number verification-support for new function isIdCardNo (num) with x ID card) {var factorArr = new Array (,); var error; var varArray = new Array (); var intValue; var lngProduct = 0; var intCheckDigit; var intStrLen = num. length; var idNumber = num; // initialize if (intStrLen! = 15) & (intStrLen! = 18) {// error = "the length of the ID card number entered is incorrect! "; // Alert (error); // frmAddUser.txt IDCard. focus (); return false;} // check and set value for (I = 0; I '9') & (I! = 17) {// error = "Incorrect ID number !. "; // Alert (error); // frmAddUser.txt IDCard. focus (); return false;} else if (I <17) {varArray [I] = varArray [I] * factorArr [I] ;}} if (intStrLen = 18) {// check date var date8 = idNumber. substring (6, 14); if (isDate8 (date8) = false) {// error = "incorrect date information in ID card !. "; // Alert (error); return false;} // calculate the sum of the products for (I = 0; I <17; I ++) {lngProduct = lngProduct + varArray [I];} // calculate the check digit intCheckDigit = 12-lngProduct % 11; switch (intCheckDigit) {case 10: intCheckDigit = 'X '; break; case 11: intCheckDigit = 0; break; case 12: intCheckDigit = 1; break;} // check last digit if (varArray [17]. toUpperCase ()! = IntCheckDigit) {// error = "Incorrect ID card verification space !... Correct: "+ intCheckDigit + ". "; // alert (error); return false ;}} else {// length is 15 // check date var date6 = idNumber. substring (6, 12); if (isDate6 (date6) = false) {// alert ("Incorrect ID Card Date information !. "); Return false ;}// alert (" Correct. "); return true;}/*** determine whether the period is in the" YYYYMM "format **/function isDate6 (sDate) {if (! /^ [0-9] {6} $ /. test (sDate) {return false;} var year, month, day; year = sDate. substring (0, 4); month = sDate. substring (4, 6); if (year <1700 | year> 2500) return false if (month <1 | month> 12) return false return true}/*** determine whether the period is in the "YYYYMMDD" format **/function isDate8 (sDate) {if (! /^ [0-9] {8} $ /. test (sDate) {return false;} var year, month, day; year = sDate. substring (0, 4); month = sDate. substring (4, 6); day = sDate. substring (6, 8); var iaMonthDays = [1700, 28, 2500, 30, 31, 31, 30, 31] if (year <| year>) return false if (year % 4 = 0) & (year % 100! = 0) | (year % 400 = 0) iaMonthDays [1] = 29; if (month <1 | month> 12) return false if (day <1 | day> iaMonthDays [month-1]) return false return true} eXtended 2 $. extend ($. fn. validatebox. defaults. rules, {idcard: {// verify ID card validator: function (value) {return/^ \ d {15} (\ d {2} [A-Za-z0-9])? $/I. test (value) ;}, message: 'incorrect ID card number format '}, minLength: {validator: function (value, param) {return value. length> = param [0];}, message: 'enter at least (2) characters. '}, length: {validator: function (value, param) {var len = $. trim (value ). length; return len> = param [0] & len <= param [1];}, message: "The length of the input content must be between {0} and {1. "}, phone: {// verification phone number validator: function (value) {return/^ (\ d {2, 3 }\)) | (\ d {3 }\-))? (\ (0 \ d {2, 3} \) | 0 \ d {2, 3 }-)? [1-9] \ d {6, 7} (\-\ d {1, 4 })? $/I. test (value) ;}, message: 'The format is incorrect. Please use the following format: 020-88888888'}, mobile: {// verify the mobile phone number validator: function (value) {return/^ (13 | 15 | 18) \ d {9} $/I. test (value) ;}, message: 'incorrect Mobile Phone Number Format '}, phoneNum: {// verify the mobile phone number + fixed phone validator: function (value) {return/^ (010) | (02 \ d) [2-8] \ d {7 }) | (0 [3-9] \ d {2} [2-8] \ d {6, 7}) | (0? (?: 147 | 1 [358] \ d) \ d {8}) $/I. test (value) ;}, message: 'incorrect Mobile Phone Number Format '}, intOrFloat: {// verify the integer or decimal validator: function (value) {return/^ \ d + (\. \ d + )? $/I. test (value) ;}, message: 'enter a number and make sure the format is correct '}, currency: {// verify the currency validator: function (value) {return/^ \ d + (\. \ d + )? $/I. test (value) ;}, message: 'currency format incorrect '}, qq: {// verify QQ, validator: function (value) from 10000) {return/^ [1-9] \ d {4, 9} $/I. test (value) ;}, message: 'incorrect QQ number format '}, integer: {// verification integer validator: function (value) {return/^ [+]? [1-9] + \ d * $/I. test (value) ;}, message: 'enter an integer '}, age: {// verify the age validator: function (value) {return/^ (?: [1-9] [0-9]? | 1 [01] [0-9] | 120) $/I. test (value) ;}, message: 'Age must be an integer between 0 and 120 '}, chinese: {// verify chinese validator: function (value) {return/^ [\ response-\ ¥] + $/I. test (value) ;}, message: 'enter Chinese '}, english: {// verify english validator: function (value) {return/^ [A-Za-z] + $/I. test (value) ;}, message: 'enter the English'}, unnormal: {// verify whether it contains spaces and invalid characters validator: function (value) {return /. +/I. test (value) ;}, message: 'The input value cannot be blank or contain other illegal characters '}, Username: {// verify username validator: function (value) {return/^ [a-zA-Z] [a-zA-Z0-9 _] {5, 15} $/I. test (value) ;}, message: 'invalid User Name (starting with a letter, 6-16 bytes allowed, letter or digit underline allowed) '}, faxno: {// verify the fax validator: function (value) {// return/^ [+] {0, 1} (\ d) {1, 3} []? ([-]? (\ D) | []) {1, 12}) + $/I. test (value); return/^ (\ d {2, 3} \) | (\ d {3 }\-))? (\ (0 \ d {2, 3} \) | 0 \ d {2, 3 }-)? [1-9] \ d {6, 7} (\-\ d {1, 4 })? $/I. test (value) ;}, message: 'incorrect fax number '}, zip: {// verify the zip code validator: function (value) {return/^ [1-9] \ d {5} $/I. test (value) ;}, message: 'incorrect zip code format '}, ip: {// verify ip address validator: function (value) {return/d +. d +. d +. d +/I. test (value) ;}, message: 'IP address format incorrect '}, name: {// verify name, which can be Chinese or English validator: function (value) {return/^ [\ response-\ ¥] + $/I. test (value) |/^ \ w + [\ w \ s] + \ w + $/I. test (value) ;}, message: 'enter the surname Name'}, date: {// verification name, which can be Chinese or English validator: function (value) {// format: yyyy-MM-dd Or yyyy-M-d return/^ (? :(?! (0000) [0-9] {4} ([-]?) (? :(?: 0? [1-9] | 1 [0-2]) \ 1 (?: 0? [1-9] | 1 [0-9] | 2 [0-8]) | (?: 0? [13-9] | 1 [0-2]) \ 1 (?: 29 | 30) | (?: 0? [1, 13578] | 1 [02]) \ 1 (?: 31) | (?: [0-9] {2 }(?: 0 [48] | [2468] [048] | [13579] [26]) | (?: 0 [48] | [2468] [048] | [13579] [26]) 00) ([-]?) 0? 2 \ 2 (?: 29) $/I. test (value) ;}, message: 'Enter the appropriate date format'}, msn: {validator: function (value) {return/^ \ w + ([-+.] \ w +) * @ \ w + ([-.] \ w + )*\. \ w + ([-.] \ w +) * $ /. test (value) ;}, message: 'enter a valid msn account (for example, abc @ hotnail (msn/live ). com) '}, same: {validator: function (value, param) {if ($ ("#" + param [0]). val ()! = "" & Value! = "") {Return $ ("#" + param [0]). val () = value ;}else {return true ;}, message: 'The passwords entered twice are inconsistent! '}); Application instance: *Mobile phone:  Official dome

Contact Us

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.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.