Easyui extending its own definition of Easyui validation rules (often used)

Source: Internet
Author: User

For example, the check input box can only enter a number with a maximum of 2 decimal places between 0-1000

Form <input type= "text" id= "rate" name= "rate" required= "true" class= "Easyui-validatebox " validtype= " RATECHECK[0,1000] " maxlength=" 6 "/>



$.extend ($.fn.validatebox.defaults.rules, {CHS: {validator:function (value, param) {return/^[\u0391-\uffe5]+$/.test (value)},message: ' Please enter Kanji '},english: {//verify English validator:function (value) {return/^[a-za-z]+$/i.test (        Value); }, message: ' Please input English '}, IP: {//Verify IP address validator:function (value) {return/\d+\.\d+\.\d+        \.\d+/.test (value);  }, message: ' IP address format is not '},zip: {validator:function (value, param) {return/^[0-9]\d{5}$/.test (value);},message: ' Zip code does not exist '},QQ: {validator:function (value, param) {return/^[1-9]\d{4,10}$/.test (value);},message: ' QQ number is incorrect '},mobile: {validator:function (value, param) {return/^ (?: 13\d|15\d|18\d)-?\d{5} (\d{3}|\*{3}) $/.test (value);},message: ' Cell phone number is not '},tel:{validator:function ' (value,param) {return/^ (\d{3}-|\d{4}-)? ( \d{8}|\d{7})? (-\d{1,6})? $/.test (value);},message: ' Phone number is not right '},mobileandtel: {validator:function (value, param) {return/(^ ([0\+]\d{ 2,3}) \d{3,4}\-\d{3,8}$) | (^ ([0\+]\d{2,3}) \d{3, 4}\d{3,8}$) | (^ ([0\+]\d{2,3}) {0,1}13\d{9}$) | (^\d{3,4}\d{3,8}$) | (^\d{3,4}\-\d{3,8}$)/.test (value);},message: ' Please enter phone number correctly '},number: {validator:function (value, param) {return/^[0-9] +.? [0-9]*$/.test (value);},message: ' Enter Number '},money:{validator:function (value, param) {return (/^ ([1-9]\d*] |\d) (\.\d{ ). $/). Test (value); }, message: ' Please enter the correct amount '},mone:{validator:function (value, param) {return (/^ ([1-9]\d*) |\d) (\.\d{1,2})? $/). Test (value ); }, message: ' Please enter an integer or decimal '},integer:{validator:function (value,param) {return/^[+]?[ 1-9]\d*$/.test (value);},message: ' Please enter an integer minimum of 1 '},integ:{validator:function (value,param) {return/^[+]?[ 0-9]\d*$/.test (value);},message: ' Enter integer '},range:{validator:function (value,param) {if (/^[1-9]\d*$/.test (value)) { return value >= param[0] && value <= param[1]}else{return false;}},message: ' The number entered is between {0} and {1} '},minlength: {validator:function (Value,param) {return value.length >=param[0]},message: ' Enter at least {0} words '},maxlength:{validator: function (Value,param) {return value.length&Lt;=param[0]},message: ' Up to {0} words '},//select that is the validation of the selection box Selectvalid:{validator:function (Value,param) {if (value = = Param[0 ]) {return false;} Else{return true;}},message: ' Please select '},idcode:{validator:function (value,param) {return/(^\d{15}$) | ( ^\d{18}$) | (^\d{17} (\d| X|X) $)/.test (value);},message: ' Please enter the correct ID number '},loginname: {validator:function (value, param) {return/^[\u0391-\uffe5\ W]+$/.test (value);},message: ' Login name only agrees with Chinese characters, English letters, numbers, and underscores. '},equalto: {validator:function (value, param) {return value = = $ (param[0]). Val ();},message: ' Two characters of input differ to '},        Englishornum: {//can only input English and digital validator:function (value) {return/^[a-za-z0-9_]{1,}$/.test (value); }, message: ' Please input English, numeric, underscore or space '}, xiaoshu:{validator:function (value) {return/^ ([1- 9]+) | ([0-9]+\. [0-9] {)})        $/.test (value); }, message: ' Keep up to two decimal places! '}, Ddprice:{validator:function (Value,param) {if (/^[1-9]\d*$/.test (value)) {return value >= param[0] &&amp ; Value <= param[1];} Else{rEturn false;}},message: ' Please enter a positive integer between 1 and 100 '},jretailupperlimit:{validator:function (Value,param) {if (/^[0-9]+ ([.] {1} [0-9] {()})? $/.test (value)) {return parsefloat (value) > parsefloat (param[0]) && parsefloat (value) <= parsefloat ( PARAM[1]);} Else{return false;}},message: ' Please enter a number of up to two decimal places between 0 and 100 '},ratecheck:{validator:function (Value,param) {if (/^[0-9]+ ([.] {1} [0-9] {()})? $/.test (value)) {return parsefloat (value) > parsefloat (param[0]) && parsefloat (value) <= parsefloat ( PARAM[1]);} Else{return false;}},message: ' Please enter a number of up to two decimal places between 0 and 1000 '}};


Easyui extending its own definition of Easyui validation rules (often used)

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.