|
|
|
|
|
by notdonspaulding
4528 days ago
|
|
If you only accept the 4 biggest card issuers, you can get away with some dead-simple code to indicate to the user what card type their number indicates they are. Personally, I bind an onkeyup event handler to fade in the appropriate icon based on the first digit of the number. This is not safe if you accept more than these 4 card types, (we don't). function detect_cc_type(number){
return {
'3': 'american_express',
'4': 'visa',
'5': 'mastercard',
'6': 'discover'
}[number[0]];
}
|
|
Also, many ATM cards (a foreign concept to this European until very recently) overlap with Visa ranges. In fact, my ATM card parses exactly as a Visa number. It even has the Visa trademark mentioned on the back. No, you can't use it for online transactions. Apparently, Visa Debit is not a thing in Canada ...
My point is, showing wrong UI is often worse than clunkier UI.