Additional: Add new BIN range for MasterCard. (#2088)

Fixes #1904
This commit is contained in:
Rob Johnston
2017-10-09 08:46:58 -04:00
committed by Brahim Arkni
parent 7e9e4788bf
commit 5ecd6c261f
2 changed files with 3 additions and 1 deletions
+1 -1
View File
@@ -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
+2
View File
@@ -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 );