diff --git a/src/additional/creditcardtypes.js b/src/additional/creditcardtypes.js index 2a61e6a7a..6b9285be7 100644 --- a/src/additional/creditcardtypes.js +++ b/src/additional/creditcardtypes.js @@ -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 diff --git a/test/methods.js b/test/methods.js index 173a2281d..3c3784bbc 100644 --- a/test/methods.js +++ b/test/methods.js @@ -1203,6 +1203,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 ); @@ -1243,6 +1244,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 );
Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.
Alternative Proxies: