Wednesday, December 19, 2018

Identify a Credit Card type Based on a Card Number

Users can identify a credit card type from a card number's numeric range and number of digits.


For MasterCard:


First digit must be a 5 and second digit must be in the range 1 through 5 inclusive. Valid length: 16 digits.


For Visa:


First digit must be a 4. Valid length: 13 or 16 digits.


For American Express:


First digit must be a 3 and second digit must be a 4 or 7. Valid length: 15 digits.


For Diners Club: 


First digit must be 3 and second digit must be 0, 6, or 8. Valid length: 14 digits.


For Discover:


Valid length: 16 digits. First 8 digits must be in one of the following ranges: 
60110000 through 60119999 
65000000 through 65999999 
62212600 through 62292599


For JCB:


First four digits must be 3088, 3096, 3112, 3158, 3337, or the first eight digits must be in the range 35280000 through 35899999. Valid length: 16 digits.

No comments:

Post a Comment