Browse Source

#332: Add UK phone number support for the phone validator, thanks to @aca02djr

nghuuphuoc 11 years ago
parent
commit
b4006d48d5
5 changed files with 5 additions and 5 deletions
  1. 1 0
      CHANGELOG.md
  2. 1 0
      README.md
  3. 1 2
      dist/js/bootstrapValidator.js
  4. 1 1
      dist/js/bootstrapValidator.min.js
  5. 1 2
      src/js/validator/phone.js

File diff suppressed because it is too large
+ 1 - 0
CHANGELOG.md


+ 1 - 0
README.md

@@ -96,6 +96,7 @@ The __BootstrapValidator__ plugin is written by Nguyen Huu Phuoc, aka @nghuuphuo
 
 Big thanks to the contributors:
 
+* [@aca02djr](https://github.com/aca02djr)
 * [@adgrafik](https://github.com/adgrafik)
 * [@alavers](https://github.com/alavers)
 * [@easonhan007](https://github.com/easonhan007)

+ 1 - 2
dist/js/bootstrapValidator.js

@@ -3617,10 +3617,9 @@
             var country = (options.country || 'US').toUpperCase();
             switch (country) {
             	case 'GB':
-            		// Make sure the input looks like a valid UK phone number based on the guide at
             		// http://aa-asterisk.org.uk/index.php/Regular_Expressions_for_Validating_and_Formatting_GB_Telephone_Numbers#Match_GB_telephone_number_in_any_format
             		// Test: http://regexr.com/38uhv
-            		value = value.trim();
+            		value = $.trim(value);
             		return (/^\(?(?:(?: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);
                 case 'US':
                 default:

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


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

@@ -26,10 +26,9 @@
             var country = (options.country || 'US').toUpperCase();
             switch (country) {
             	case 'GB':
-            		// Make sure the input looks like a valid UK phone number based on the guide at
             		// http://aa-asterisk.org.uk/index.php/Regular_Expressions_for_Validating_and_Formatting_GB_Telephone_Numbers#Match_GB_telephone_number_in_any_format
             		// Test: http://regexr.com/38uhv
-            		value = value.trim();
+            		value = $.trim(value);
             		return (/^\(?(?:(?: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);
                 case 'US':
                 default: