Jqueryi validatebox extends its built-in verification method

Source: Internet
Author: User
Tags email account

$. Extend ($. FN. validatebox. defaults. Rules ,{
Minlength: {// judge the minimum length
Validator: function (value, Param ){
Returnvalue. length> = Param [0];
},
Message: 'enter at least {0} characters. '
},
Length: {validator: function (value, Param ){
Varlen = $. Trim (value). length;
Returnlen> = Param [0] & Len <= Param [1];
},
Message: "The length of the input content must be between {0} and {1 ."
},
Phone: {// verify the 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: 'format is incorrect. Please use the following format: 020-888888888888'
},
Mobile: {// verify the mobile phone number
Validator: function (value ){
Return/^ (13 | 15 | 18) \ D {9} $/I. Test (value );
},
Message: 'incorrect Mobile Phone Number Format'
},
Idcard: {// verify the ID card
Validator: function (value ){
Return/^ \ D {15} (\ D {2} [A-Za-z0-9])? $/I. Test (value );
},
Message: 'incorrect ID card number format'
},
Intorfloat: {// verify the integer or decimal number
Validator: function (value ){
Return/^ \ D + (\. \ D + )? $/I. Test (value );
},
Message: 'enter a number and make sure the format is correct'
},
Currency: {// verify currency
Validator: function (value ){
Return/^ \ D + (\. \ D + )? $/I. Test (value );
},
Message: 'invalid currency format'
},
QQ: {// verify QQ, from 10000
Validator: function (value ){
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'
},
Chinese: {// verify Chinese
Validator: function (value ){
Return/^ [\ u0391-\ uffe5] + $/I. Test (value );
},
Message: 'enter Chinese characters'
},
English: {// verify English
Validator: function (value ){
Return/^ [A-Za-Z] + $/I. Test (value );
},
Message: 'enter English'
},
Unnormal: {// verify whether the string 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 the user name
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, with letters, numbers, and underscores 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 the IP address
Validator: function (value ){
Return/d +. d +/I. Test (value );
},
Message: 'incorrect IP address format'
},
Name: {// verification name, which can be Chinese or English
Validator: function (value ){
Return/^ [\ u0391-\ uffe5] + $/I. test (value) |/^ \ W + [\ W \ s] + \ W + $/I. test (value );
},
Message: 'enter your name'
},
Carno :{
Validator: function (value ){
Return/^ [\ u4e00-\ u9fa5] [\ da-Za-Z] {6} $/. Test (value );
},
Message: 'invalid license plate number (e.g. Guangdong j12350 )'
},
Carenergin :{
Validator: function (value ){
Return/^ [a-zA-Z0-9] {16} $/. Test (value );
},
Message: 'invalid engine model (for example, fg6h012345654584 )'
},
Email :{
Validator: function (value ){
Return/^ \ W + ([-+.] \ W +) * @ \ W + ([-.] \ W + )*\. \ W + ([-.] \ W +) * $ /. test (value );
},
Message: 'enter a valid email account (for example, abc@126.com )'
},
MSN :{
Validator: function (value ){
Return/^ \ W + ([-+.] \ W +) * @ \ W + ([-.] \ W + )*\. \ W + ([-.] \ W +) * $ /. test (value );
},
Message: 'enter a valid MSN account (e.g. ABC @ hotnail (MSN/live). com )'
}, Same :{
Validator: function (value, Param ){
If ($ ("#" + Param [0]). Val ()! = "" & Value! = ""){
Return $ ("#" + Param [0]). Val () = value;
} Else {
Returntrue;
}
},
Message: 'The passwords entered twice are inconsistent! '
}
});

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.