mirror of
https://github.com/jquery-validation/jquery-validation.git
synced 2026-06-12 15:37:05 +02:00
This commit is contained in:
committed by
Markus Staab
parent
660a4777d4
commit
fc25612ef0
@@ -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
@@ -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" );
|
||||
} );
|
||||
|
||||
Reference in New Issue
Block a user