Additional: allow N11 exchange for non-geo US phone. Fixes #1695 (#2098)

This commit is contained in:
Keith Morrison
2018-02-14 00:04:06 -08:00
committed by Markus Staab
parent 660a4777d4
commit fc25612ef0
2 changed files with 2 additions and 2 deletions
+1 -1
View File
@@ -17,5 +17,5 @@
$.validator.addMethod( "phoneUS", function( phone_number, element ) {
phone_number = phone_number.replace( /\s+/g, "" );
return this.optional( element ) || phone_number.length > 9 &&
phone_number.match( /^(\+?1-?)?(\([2-9]([02-9]\d|1[02-9])\)|[2-9]([02-9]\d|1[02-9]))-?[2-9]([02-9]\d|1[02-9])-?\d{4}$/ );
phone_number.match( /^(\+?1-?)?(\([2-9]([02-9]\d|1[02-9])\)|[2-9]([02-9]\d|1[02-9]))-?[2-9]\d{2}-?\d{4}$/ );
}, "Please specify a valid phone number" );
+1 -1
View File
@@ -814,9 +814,9 @@ QUnit.test( "phone (us)", function( assert ) {
assert.ok( method( "1(212)-999-2345" ), "Valid US phone number" );
assert.ok( method( "212 999 2344" ), "Valid US phone number" );
assert.ok( method( "212-999-0983" ), "Valid US phone number" );
assert.ok( method( "234-911-5678" ), "Valid US phone number" );
assert.ok( !method( "111-123-5434" ), "Invalid US phone number. Area Code cannot start with 1" );
assert.ok( !method( "212 123 4567" ), "Invalid US phone number. NXX cannot start with 1" );
assert.ok( !method( "234-911-5678" ), "Invalid US phone number, because the exchange code cannot be in the form N11" );
assert.ok( !method( "911-333-5678" ), "Invalid US phone number, because the area code cannot be in the form N11" );
assert.ok( method( "234-912-5678" ), "Valid US phone number" );
} );