mirror of
https://github.com/jquery-validation/jquery-validation.git
synced 2026-06-12 15:37:05 +02:00
committed by
Brahim Arkni
parent
7e9e4788bf
commit
5ecd6c261f
@@ -38,7 +38,7 @@ $.validator.addMethod( "creditcardtypes", function( value, element, param ) {
|
||||
if ( param.all ) {
|
||||
validTypes = 0x0001 | 0x0002 | 0x0004 | 0x0008 | 0x0010 | 0x0020 | 0x0040 | 0x0080;
|
||||
}
|
||||
if ( validTypes & 0x0001 && /^(5[12345])/.test( value ) ) { // Mastercard
|
||||
if ( validTypes & 0x0001 && ( /^(5[12345])/.test( value ) || /^(2[234567])/.test( value ) ) ) { // Mastercard
|
||||
return value.length === 16;
|
||||
}
|
||||
if ( validTypes & 0x0002 && /^(4)/.test( value ) ) { // Visa
|
||||
|
||||
@@ -1236,6 +1236,7 @@ QUnit.test( "creditcardtypes, all", function( assert ) {
|
||||
} );
|
||||
|
||||
testCardTypeByNumber( assert, "4111-1111-1111-1111", "VISA", true );
|
||||
testCardTypeByNumber( assert, "2211-1111-1111-1114", "MasterCard", true );
|
||||
testCardTypeByNumber( assert, "5111-1111-1111-1118", "MasterCard", true );
|
||||
testCardTypeByNumber( assert, "6111-1111-1111-1116", "Discover", true );
|
||||
testCardTypeByNumber( assert, "3400-0000-0000-009", "AMEX", true );
|
||||
@@ -1276,6 +1277,7 @@ QUnit.test( "creditcardtypes, mastercard", function( assert ) {
|
||||
}
|
||||
} );
|
||||
|
||||
testCardTypeByNumber( assert, "2211-1111-1111-1114", "MasterCard", true );
|
||||
testCardTypeByNumber( assert, "5111-1111-1111-1118", "MasterCard", true );
|
||||
testCardTypeByNumber( assert, "6111-1111-1111-1116", "Discover", false );
|
||||
testCardTypeByNumber( assert, "3400-0000-0000-009", "AMEX", false );
|
||||
|
||||
Reference in New Issue
Block a user