Browse Source

phone validator add support for china phone.

caijh 11 years ago
parent
commit
efa022041d
1 changed files with 5 additions and 2 deletions
  1. 5 2
      src/js/validator/phone.js

+ 5 - 2
src/js/validator/phone.js

@@ -21,7 +21,7 @@
         },
 
         // The supported countries
-        COUNTRY_CODES: ['BR', 'ES', 'FR', 'GB', 'MA', 'PK', 'US'],
+        COUNTRY_CODES: ['BR', 'ES', 'FR', 'GB', 'MA', 'PK', 'US', 'CN'],
 
         /**
          * Return true if the input value contains a valid phone number for the country
@@ -97,7 +97,10 @@
                     value   = $.trim(value);
                     isValid = (/^0?3[0-9]{2}[0-9]{7}$/).test(value);
                     break;
-                
+                case 'CN':
+                    value   = $.trim(value);
+                    isValid = (/^((\+86)|(86))?((\d{11})|^((\d{7,8})|(\d{4}|\d{3})-(\d{7,8})|(\d{4}|\d{3})-(\d{7,8})-(\d{4}|\d{3}|\d{2}|\d{1})|(\d{7,8})-(\d{4}|\d{3}|\d{2}|\d{1}))$)/).test(value);
+                    break;
                 case 'US':
                 /* falls through */
                 default: