Browse Source

#171: The phone validator now supports +1 country code and area code for US phone number, thanks to @tomByrer

phuoc 12 years ago
parent
commit
0696279474
3 changed files with 5 additions and 3 deletions
  1. 1 0
      CHANGELOG.md
  2. 1 0
      README.md
  3. 3 3
      src/js/validator/phone.js

+ 1 - 0
CHANGELOG.md

@@ -3,6 +3,7 @@
 ## v0.4.2 (not released yet)
 
 * [#168](https://github.com/nghuuphuoc/bootstrapvalidator/pull/168): Add siren and siret validators, thanks to [@jswale](https://github.com/jswale)
+* [#171](https://github.com/nghuuphuoc/bootstrapvalidator/pull/171): The [```phone``` validator](http://bootstrapvalidator.com/validators/phone/) now supports +1 country code and area code for US phone number, thanks to [@tomByrer](https://github.com/tomByrer)
 
 ## v0.4.1 (2014-04-12)
 

+ 1 - 0
README.md

@@ -60,6 +60,7 @@ Big thanks to the contributors:
 * [@narutosanjiv](https://github.com/narutosanjiv)
 * [@patmoore](https://github.com/patmoore)
 * [@vaz](https://github.com/vaz)
+* [@tomByrer](https://github.com/tomByrer)
 * ... might be you! Let's [fork](https://github.com/nghuuphuoc/bootstrapvalidator/fork) and pull a request!
 
 ## License

+ 3 - 3
src/js/validator/phone.js

@@ -27,9 +27,9 @@
                 case 'US':
                 default:
                     // Make sure US phone numbers have 10 digits
-                    // may start with 1, +1, or 1-; should discard
-                    // area code may be delimited with (), & sections may be delimited with . or -
-                    // test: http://regexr.com/38mqi
+                    // May start with 1, +1, or 1-; should discard
+                    // Area code may be delimited with (), & sections may be delimited with . or -
+                    // Test: http://regexr.com/38mqi
                     value = value.replace(/\(|\)|\s+/g, '');
                     return (/^(?:(1\-?)|(\+1 ?))?\(?(\d{3})[\)\-\.]?(\d{3})[\-\.]?(\d{4})$/).test(value) && (value.length == 10);
             }