5 ms·
You don't need that for pure number validation, no, but it can be a useful heuristic for short-circuiting your validation -- if someone enters a number which sh
by ubernostrum 17y ago
You don't need that for pure number validation, no, but it can be a useful heuristic for short-circuiting your validation -- if someone enters a number which should be Visa but clicks "MasterCard", you know something is wrong and should kick back an immediate error message rather than proceeding.
- brk 17y agoIME, all you "know" is that they entered the number and forgot to pick the proper corresponding card type. The requirement to select a card type always seems wrong to me. When you swipe a card at a terminal, you don't have to tell it if you're swiping an AmEx or a Visa. It can tell JUST from the number.
- Confusion 17y agoThe chance of someone making a typo and still having entered a valid cc number is quite small.
- ubernostrum 17y agoIt's more a question of whether you even continue to validate the number at that point; personally I'd choose not to since you already know something's wrong. Hence I treat it as a short-circuit validation trick.
- Confusion 17y agoBut that already assumes that you ask the card type in the first place. There's no need for that and hence no possibility to choose to stop validation. It smells like premature optimization to ask the cc type for this reason?