Browse Source

Add DK phone validator

Emil Rømer Christensen 11 years ago
parent
commit
51706be138

+ 1 - 1
dist/css/bootstrapValidator.min.css

@@ -2,7 +2,7 @@
  * BootstrapValidator (http://bootstrapvalidator.com)
  * The best jQuery plugin to validate form fields. Designed to use with Bootstrap 3
  *
- * @version     v0.5.2-dev, built on 2014-09-04 9:51:18 PM
+ * @version     v0.5.2-dev, built on 2014-09-05 12:47:55 PM
  * @author      https://twitter.com/nghuuphuoc
  * @copyright   (c) 2013 - 2014 Nguyen Huu Phuoc
  * @license     MIT

+ 12 - 2
dist/js/bootstrapValidator.js

@@ -2,7 +2,7 @@
  * BootstrapValidator (http://bootstrapvalidator.com)
  * The best jQuery plugin to validate form fields. Designed to use with Bootstrap 3
  *
- * @version     v0.5.2-dev, built on 2014-09-04 9:51:18 PM
+ * @version     v0.5.2-dev, built on 2014-09-05 12:47:55 PM
  * @author      https://twitter.com/nghuuphuoc
  * @copyright   (c) 2013 - 2014 Nguyen Huu Phuoc
  * @license     MIT
@@ -4748,6 +4748,7 @@
         countries: {
             BR: 'Brazil',
             CN: 'China',
+            DK: 'Denmark',
             ES: 'Spain',
             FR: 'France',
             GB: 'United Kingdom',
@@ -4765,7 +4766,7 @@
         },
 
         // The supported countries
-        COUNTRY_CODES: ['BR', 'CN', 'ES', 'FR', 'GB', 'MA', 'PK', 'RO', 'US'],
+        COUNTRY_CODES: ['BR', 'CN', 'DK', 'ES', 'FR', 'GB', 'MA', 'PK', 'RO', 'US'],
 
         /**
          * Return true if the input value contains a valid phone number for the country
@@ -4816,6 +4817,15 @@
                     isValid = (/^((00|\+)?(86(?:-| )))?((\d{11})|(\d{3}[- ]{1}\d{4}[- ]{1}\d{4})|((\d{2,4}[- ]){1}(\d{7,8}|(\d{3,4}[- ]{1}\d{4}))([- ]{1}\d{1,4})?))$/).test(value);
                     break;
 
+                case 'DK':
+                    // Mathing DK phone numbers with country code in 1 of 3 formats and an
+                    // 8 digit phone number not starting with a 0 or 1. Can have 1 space
+                    // between each character except inside the country code.
+                    // Test: http://regex101.com/r/sS8fO4/1
+                    value   = $.trim(value);
+                    isValid = (/^(\+45|0045|\(45\))?\s?[2-9](\s?\d){7}$/).test(value);
+                    break;
+
                 case 'ES':
                     // http://regex101.com/r/rB9mA9/1
                     value   = $.trim(value);

File diff suppressed because it is too large
+ 2 - 2
dist/js/bootstrapValidator.min.js


+ 1 - 0
dist/js/language/da_DK.js

@@ -230,6 +230,7 @@
             countries: {
                 BR: 'Brasilien',
                 CN: 'Kina',
+                DK: 'Danmark',
                 ES: 'Spanien',
                 FR: 'Frankrig',
                 GB: 'Storbritannien',

+ 1 - 0
src/js/language/da_DK.js

@@ -230,6 +230,7 @@
             countries: {
                 BR: 'Brasilien',
                 CN: 'Kina',
+                DK: 'Danmark',
                 ES: 'Spanien',
                 FR: 'Frankrig',
                 GB: 'Storbritannien',

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

@@ -6,6 +6,7 @@
         countries: {
             BR: 'Brazil',
             CN: 'China',
+            DK: 'Denmark',
             ES: 'Spain',
             FR: 'France',
             GB: 'United Kingdom',
@@ -23,7 +24,7 @@
         },
 
         // The supported countries
-        COUNTRY_CODES: ['BR', 'CN', 'ES', 'FR', 'GB', 'MA', 'PK', 'RO', 'US'],
+        COUNTRY_CODES: ['BR', 'CN', 'DK', 'ES', 'FR', 'GB', 'MA', 'PK', 'RO', 'US'],
 
         /**
          * Return true if the input value contains a valid phone number for the country
@@ -74,6 +75,15 @@
                     isValid = (/^((00|\+)?(86(?:-| )))?((\d{11})|(\d{3}[- ]{1}\d{4}[- ]{1}\d{4})|((\d{2,4}[- ]){1}(\d{7,8}|(\d{3,4}[- ]{1}\d{4}))([- ]{1}\d{1,4})?))$/).test(value);
                     break;
 
+                case 'DK':
+                    // Mathing DK phone numbers with country code in 1 of 3 formats and an
+                    // 8 digit phone number not starting with a 0 or 1. Can have 1 space
+                    // between each character except inside the country code.
+                    // Test: http://regex101.com/r/sS8fO4/1
+                    value   = $.trim(value);
+                    isValid = (/^(\+45|0045|\(45\))?\s?[2-9](\s?\d){7}$/).test(value);
+                    break;
+
                 case 'ES':
                     // http://regex101.com/r/rB9mA9/1
                     value   = $.trim(value);