Jquery Easyui verification extension, Easyui verification, Easyui verification, js regular expression, jqueryeasyui
Jquery Easyui verification extension, Easyui verification, Easyui verification, and js Regular Expressions
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
Sweet potato Yao, January 9, 2017 08:52:19 Monday
Http://www.cnblogs.com/fanshuyao/
1. Extended easyui verification rules
/* EasyUI Built-in validation * // * email: Match email regex rule. url: Match URL regex rule. length [0,100]: Between x and x characters allowed. remote [' http://.../action.do ', 'Paramname']: Send ajax request to do validate value, return 'true' when successfully. */$. extend ($. fn. validatebox. defaults. rules, {phone: {// cell phone number verification validator: function (value, param) {return checkPhone (value) ;}, message: 'enter the correct mobile phone number. '}, MyEmail: {// email verification to avoid conflict between email and default validator: function (value, param) {return checkEmail (value);}, message: 'Enter the correct mailbox '}, loginName: {// login name, number, English letter or underline validator: function (value, param) {return checkLoginName (value );}, message: 'Only numbers, English letters, or underscores can be entered '}, telePhone: {// landline, area code and extension code can have validator: function (value, param) {return checkTelePhone (value) ;}, message: 'Enter the correct landline number '}, chinese: {// validato R: function (value, param) {return checkChinese (value) ;}, message: 'Only Chinese characters can be entered '}, number: {// positive integer, including 0 (non-numbers) validator: function (value, param) {return isNumber (value) ;}, message: 'Only numbers (01 not numbers) '}, numberText: {// a string composed of numbers, such as 000222,22220000, 00000 validator: function (value, param) {return isNumberText (value) ;}, message: 'Only digit string '}, idCardNo: {// ID card validator: function (value, param) {return I SIdCardNo (value) ;}, message: 'Enter the correct ID card number'}, money: {// amount validator: function (value, param) {return isFloat (value) ;}, message: 'Enter the correct number'}, floatNumber: {// number (including a positive integer, 0, floating point number) validator: function (value, param) {return isFloat (value) ;}, message: 'Enter the correct number'}, minLength: {validator: function (value, param) {return value. length> = param [0] ;}, message: 'enter at least {0} characters. '}, MaxLength: {validator: function (value, param) {return value. length <= param [0] ;}, message:' cannot exceed {0} characters. '}});
Ii. Use
Add the attribute validType: 'phone' to data-option, as shown in the following figure:
Html code
- Data-options = "required: true, validType: 'phone '"
Html code
- Data-options = "required: false, validType: 'telphone '"
Iii. Partial verification methods
/*** Remove the leading and trailing spaces of the string * @ param str input string value * @ author lqy * @ since 2015-08-21 */function trim (str) {if (str = null) {return "";} return str. replace (/(^ \ s *) | (\ s * $)/g ,"");}; /*** whether it is Null * @ param object * @ returns {Boolean} */function isNull (object) {if (object = null | typeof object = "undefined") {return true;} return false ;};/*** whether it is a null string, A space is not an empty string * @ param str * @ returns {Boolean} */function isEmpty (str) {if (str = null | typeof str = "undefined" | str = "") {return true ;}return false ;}; /*** whether it is a null string and all spaces are empty strings * @ param str * @ returns {Boolean} */function isBlank (str) {if (str = null | typeof str = "undefined" | str = "" | trim (str) = "") {return true ;} return false ;};
/*** Check the mobile phone number * @ param z_check_value the value to be checked * @ return returns true, no false * @ since 2015-08-21 */function checkPhone (z_check_value) {if (isEmpty (z_check_value) | z_check_value.length! = 11) {return false ;} var z_reg =/^ 13 [0-9] {9} | 15 [012356789] [0-9] {8} | 18 [0-9] {9} | (14 [57] [0-9] {8 }) | (17 [015678] [0-9] {8}) $/; return z_reg.test (z_check_value );};
/*** Check the email address * @ param z_check_value the value to be checked * @ return returns true If yes, no false * @ since 2015-08-21 */function checkEmail (z_check_value) {// var emailReg =/^ ([a-zA-Z0-9] + [_ | \.]?) * [A-zA-Z0-9] + @ ([a-zA-Z0-9] + [_ | \.]?) * [A-zA-Z0-9] + \. [a-zA-Z] {2, 3} $/; var z_reg =/^ \ w + (-\ w +) | (\. \ w +) * \ @ [A-Za-z0-9] + ((\. |-) [A-Za-z0-9] + )*\. [A-Za-z0-9] + $/; return z_reg.test ($. trim (z_check_value ));};
/*** Check the login name (a string consisting of digits, 26 English letters, or underscores) * @ param z_check_value the value to be checked * @ return returns true, no false * @ since 2015-12-29 */function checkLoginName (z_check_value) {var z_reg =/^ \ w + $/; return z_reg.test ($. trim (z_check_value ));};
/*** Check the phone number * @ param z_check_value the value to be checked * @ return returns true If yes, no false * @ since 2015-08-21 */function checkTelePhone (z_check_value) {var z_reg =/^ ([0 \ +] \ d {2, 3 }-)? (0 \ d {2, 3 })-)? (\ D {7,8}) (-(\ d {3,4 }))? $/; Return z_reg.test ($. trim (z_check_value ));};
/*** Check Chinese only * @ param z_check_value the value to be checked * @ return returns true, no false * @ since 2015-08-21 */function checkChinese (z_check_value) {var z_reg =/^ [\ u4E00-\ u9FA5 \ uF900-\ uFA2D] + $/; return z_reg.test ($. trim (z_check_value ));};
/*** Whether it is a number * @ param z_check_value the value to be checked * @ return returns true, no false * @ since 2016-10-31 */function isNumber (z_check_value) {var z_reg =/^ ([0-9]) | ([1-9] ([0-9] +) $/; return z_reg.test ($. trim (z_check_value ));};
/*** Indicates whether the string is composed of digits. 01 also complies with the Rule * @ param z_check_value: the value to be checked * @ return returns true, no false * @ since 2017-01-07 */function isNumberText (z_check_value) {var z_reg =/^ ([0-9] +) $/; return z_reg.test ($. trim (z_check_value ));};
/*** Determines whether it is a number, amount, floating point number * @ param z_check_value the value to be checked * @ return returns true, no false * @ author lqy * @ since 2017-01-07 */function isFloat (z_check_value) {var z_reg =/^ ([0-9]) | ([1-9] [0-9] + ))(\. ([0-9] + ))?) $/; //. It is a special character and needs to be escaped return z_reg.test ($. trim (z_check_value ));};
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
Sweet potato Yao, January 9, 2017 08:52:19 Monday
Http://www.cnblogs.com/fanshuyao/