Browse Source

Merge branch 'abuzer-pk-mobile-validate'

Phuoc Nguyen 11 years ago
parent
commit
2c50cd404a
1 changed files with 8 additions and 1 deletions
  1. 8 1
      src/js/validator/phone.js

+ 8 - 1
src/js/validator/phone.js

@@ -9,6 +9,7 @@
             FR: 'France',
             FR: 'France',
             GB: 'United Kingdom',
             GB: 'United Kingdom',
             MA: 'Morocco',
             MA: 'Morocco',
+            PK: 'Pakistan',
             US: 'USA'
             US: 'USA'
         }
         }
     });
     });
@@ -20,7 +21,7 @@
         },
         },
 
 
         // The supported countries
         // The supported countries
-        COUNTRY_CODES: ['BR', 'ES', 'FR', 'GB', 'MA', 'US'],
+        COUNTRY_CODES: ['BR', 'ES', 'FR', 'GB', 'MA', 'PK', 'US'],
 
 
         /**
         /**
          * Return true if the input value contains a valid phone number for the country
          * Return true if the input value contains a valid phone number for the country
@@ -91,6 +92,12 @@
                     isValid = (/^(?:(?:(?:\+|00)212[\s]?(?:[\s]?\(0\)[\s]?)?)|0){1}(?:5[\s.-]?[2-3]|6[\s.-]?[13-9]){1}[0-9]{1}(?:[\s.-]?\d{2}){3}$/).test(value);
                     isValid = (/^(?:(?:(?:\+|00)212[\s]?(?:[\s]?\(0\)[\s]?)?)|0){1}(?:5[\s.-]?[2-3]|6[\s.-]?[13-9]){1}[0-9]{1}(?:[\s.-]?\d{2}){3}$/).test(value);
                     break;
                     break;
                 
                 
+                case 'PK':
+                    // http://regex101.com/r/yH8aV9/2
+                    value   = $.trim(value);
+                    isValid = (/^0?3[0-9]{2}[0-9]{7}$/).test(value);
+                    break;
+                
                 case 'US':
                 case 'US':
                 /* falls through */
                 /* falls through */
                 default:
                 default: