Jqueryeasyui validatebox Extension

Source: Internet
Author: User
Tags email account

Jqueryeasyui validatebox comes with several built-in verification methods, such as non-empty, mailbox, asynchronous, and character length verification methods. However, these methods are far from satisfying our own needs, I sorted out some extension methods to enrich the verification methods!

 1   $. Extend ($. FN. validatebox. defaults. Rules ,{  2 Minlength :{ //  Minimum Length  3 Validator: Function  (Value, Param ){  4 Returnvalue. length> = Param [0 ];  5  },  6 Message: 'enter at least {0} characters. ' 7   },  8 Length: {validator: Function  (Value, Param ){  9 Varlen = $. Trim (value). length;  10 Returnlen> = Param [0] & Len <= Param [1 ];  11   },  12 Message: "The length of the input content must be between {0} and {1 ."13   },  14 Phone :{ //  Verify phone number  15 Validator: Function  (Value ){  16   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 );  17   },  18 Message: 'format is incorrect. Please use the following format: 020-888888888888'19   },  20 Mobile :{ //  Verify mobile phone number  21 Validator: Function  (Value ){  22   Return /^ (13 | 15 | 18) \ D {9} $/ I. Test (value );  23   },  24 Message: 'incorrect Mobile Phone Number Format' 25  },  26 Idcard :{ //  Verify ID card  27 Validator: Function  (Value ){  28   Return /^ \ D {15} (\ D {2} [A-Za-z0-9])? $/ I. Test (value );  29   },  30 Message: 'incorrect ID card number format' 31   }, 32 Intorfloat :{ //  Verify integer or decimal number  33 Validator: Function  (Value ){  34   Return /^ \ D + (\. \ D + )? $/ I. Test (value );  35   },  36 Message: 'enter a number and make sure the format is correct' 37   },  38 Currency :{//  Verify currency  39 Validator: Function  (Value ){  40   Return /^ \ D + (\. \ D + )? $/ I. Test (value );  41   },  42 Message: 'invalid currency format' 43   },  44 QQ :{ // Verify QQ, starting from 10000  45 Validator: Function  (Value ){  46   Return /^ [1-9] \ D {4, 9} $/ I. Test (value );  47   },  48 Message: 'incorrect QQ number format' 49   },  50 Integer :{ //  Verification integer 51 Validator: Function  (Value ){  52   Return /^ [+]? [1-9] + \ D * $/ I. Test (value );  53   },  54 Message: 'enter an integer' 55   },  56 Chinese :{ //  Verify Chinese  57 Validator:Function  (Value ){  58   Return /^ [\ U0391-\ uffe5] + $/ I. Test (value );  59   },  60 Message: 'enter Chinese characters' 61   },  62 English :{ //  Verify English  63 Validator: Function (Value ){  64   Return /^ [A-Za-Z] + $/ I. Test (value );  65   },  66 Message: 'enter English' 67   },  68 Unnormal :{ //  Verify that the bucket contains spaces and invalid characters.  69 Validator: Function  (Value ){ 70   Return /. +/ I. Test (value );  71   },  72 Message: 'The input value cannot be blank or contain other illegal characters' 73   },  74 Username :{ //  Verify User Name  75 Validator: Function  (Value ){  76  Return /^ [A-Za-Z] [a-zA-Z0-9 _] {5, 15} $/ I. Test (value );  77   },  78 Message: 'invalid User Name (starting with a letter, 6-16 bytes allowed, with letters, numbers, and underscores allowed )' 79   },  80 Faxno :{ //  Verify Fax  81 Validator: Function  (Value ){  82   // Return/^ [+] {0, 1} (\ D) {1, 3} []? ([-]? (\ D) | []) {1, 12}) + $/I. Test (value );  83   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 );  84   },  85 Message: 'incorrect Fax number' 86   },  87 ZIP :{ //  Verify zip code  88 Validator:Function  (Value ){  89   Return /^ [1-9] \ D {5} $/ I. Test (value );  90   },  91 Message: 'incorrect zip code format' 92   },  93 IP :{ //  Verify IP Address  94 Validator: Function (Value ){  95   Return /D +. d +/ I. Test (value );  96   },  97 Message: 'incorrect IP address format' 98   },  99 Name :{ //  Verification name, which can be Chinese or English  100 Validator: Function  (Value ){ 101   Return /^ [\ U0391-\ uffe5] + $/I. Test (value) |/^ \ W + [\ W \ s] + \ W + $/ I. Test (value );  102   },  103 Message: 'enter your name' 104   },  105   Carno :{  106 Validator: Function  (Value ){  107   Return /^ [\ U4e00-\ u9fa5] [\ da-Za-Z] {6} $/ . Test (value );  108   },  109 Message: 'invalid license plate number (e.g. Guangdong j12350 )' 110   },  111   Carenergin :{  112 Validator: Function  (Value ){  113   Return /^ [A-zA-Z0-9] {16} $/ . Test (value ); 114   },  115 Message: 'invalid engine model (for example, fg6h012345654584 )' 116   },  117   Email :{  118 Validator: Function  (Value ){  119   Return /^ \ W + ([-+.] \ W +) * @ \ W + ([-.] \ W + )*\. \ W + ([-.] \ W +) * $/ . Test (value );  120   }, 121 Message: 'enter a valid email account (for example, abc@126.com )' 122   },  123   MSN :{  124 Validator: Function  (Value ){  125   Return /^ \ W + ([-+.] \ W +) * @ \ W + ([-.] \ W + )*\. \ W + ([-.] \ W +) * $/ . Test (value );  126   },  127 Message: 'enter a valid MSN account (e.g. ABC @ hotnail (MSN/live). com )'128   }, Same :{  129 Validator: Function  (Value, Param ){  130   If ($ ("#" + Param [0]). Val ()! = "" & Value! = "" ){  131   Return $ ("#" + Param [0]). Val () = Value;  132 } Else  {  133  Returntrue;  134   }  135   },  136 Message: 'The passwords entered twice are inconsistent! ' 137   }  138 });

Usage:

<InputID= "VV"Class= "Easyui-validatebox"Data-Options= "Validtype: 'China '" />

I hope this will help you!

 

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.