Browse Source

Merge pull request #510 from dlucazeau/master

French phone number validation
Phuoc Nguyen 11 years ago
parent
commit
bb6fbb3296
1 changed files with 8 additions and 1 deletions
  1. 8 1
      src/js/validator/phone.js

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

@@ -5,6 +5,7 @@
         country: 'Please enter a valid phone number in %s',
         countries: {
             GB: 'United Kingdom',
+            FR: 'France',
             US: 'USA'
         }
     });
@@ -16,7 +17,7 @@
         },
 
         // The supported countries
-        COUNTRY_CODES: ['GB', 'US'],
+        COUNTRY_CODES: ['GB', 'FR', US'],
 
         /**
          * Return true if the input value contains a valid phone number for the country
@@ -63,6 +64,12 @@
             		isValid = (/^\(?(?:(?:0(?:0|11)\)?[\s-]?\(?|\+)44\)?[\s-]?\(?(?:0\)?[\s-]?\(?)?|0)(?:\d{2}\)?[\s-]?\d{4}[\s-]?\d{4}|\d{3}\)?[\s-]?\d{3}[\s-]?\d{3,4}|\d{4}\)?[\s-]?(?:\d{5}|\d{3}[\s-]?\d{3})|\d{5}\)?[\s-]?\d{4,5}|8(?:00[\s-]?11[\s-]?11|45[\s-]?46[\s-]?4\d))(?:(?:[\s-]?(?:x|ext\.?\s?|\#)\d+)?)$/).test(value);
                     break;
 
+                case 'FR':
+                    // http://regexr.com/395dq
+                    value = $.trim(value);
+                    isValid = (/^(?:(?:(?:\+|00)33\D?(?:\D?\(0\)\D?)?)|0){1}[1-9]{1}(?:\D?\d{2}){4}$/).test(value);
+                    break;
+
                 case 'US':
                 /* falls through */
                 default: