4 ms·
This looks great, but any code that attempts to guess the card type using the first few numbers always makes me nervous
by wwarren 12y ago
This looks great, but any code that attempts to guess the card type using the first few numbers always makes me nervous
- bluetidepro 12y agoWhy does it make you nervous? I was under the impression it was pretty fool proof? See: http://stackoverflow.com/questions/72768/how-do-you-detect-credit-card-type-based-on-number http://stackoverflow.com/questions/72768/how-do-you-detect-c...
- recursive 12y agoFYI, the expression is "fool proof"
- bluetidepro 12y agoFixed, thanks! :)
- pit 12y agoMaybe there could be a version that doesn't try to guess the card and uses a generic card background.
- saryant 12y agoCredit card numbers contain a unique ID for the issuer: http://en.wikipedia.org/wiki/Bank_card_number#Major_Industry_Identifier_.28MII.29 http://en.wikipedia.org/wiki/Bank_card_number#Major_Industry...
- squeaky-clean 12y agoAny reason why? It's a pretty straightforward system that card companies use. For example every Visa card begins with a 4, and only Visa cards begin with a 4.
- deleted 12y ago[deleted]
- AhtiK 12y agoAlso fun if the last digit would be autofilled based on Luhn algorithm :)
- Igglyboo 12y agoHe's not really "guessing" the card type, there's a pretty standard algorithm called the Luhn Algorithm that all credit card companies use when issuing their cards. The algorithm is public domain and all it does is tell you who issued the card which doesn't seem like an issue to me
- harlanlewis 12y agoIt isn't providing a visual for all credit card issuers, though (eg Diner's Club, JCB). Those cards may still be processed correctly (I don't have any way of verifying), but visually treating a correct input like an invalid input isn't going to help conversion much. Easily solved by simply adding treatments for more card types, and styling the entire card isn't that much more effort than just displaying an issuer logo. Where this starts to get really interesting (from a slick + branded perspective) is when you start handling gift cards.