How do I validate Credit Card and Bank Account numbers? [closed]
Asked Answered
G

1

16

I know there have been a lot of discussion related to this topic, e.g. Credit Card validation: can Card Name contain non-ASCII characters?

The reason I wanted to ask this question is because people could find all the information at one place.

What I've found out (Please correct me if/where I'm wrong):

Title - Length - Format

Credit Card Number - MIN 13, MAX 19 - Numeric

Credit Card Name - MAX 26 - Alpha Numeric (Cannot contain dots after Initials?)

Bank Account Number (btw, I'm in India) - MIN 11, MAX 15 - Numeric

Bank Account Name - Sorry, no idea - Alpha Numeric? (again, no idea)

Please provide answers so that this will help people who have to juggle with financial data.

Guglielmo answered 6/10, 2012 at 17:9 Comment(3)
Guys, please dont close this. You have no idea how scattered Card Validation Info is, on the Internet. Search and you'll knowGuglielmo
as far as i know, u're right about the credit card numbers.Vergeboard
Thing is you can't validate this with confidence. Definition of card number and rest of data is changing in time. Not frequently, but just enough to produce fire in production after few months of years, when you least expect that to happen. You validate something when you know its definition. If definition is not satisfied its invalid. Thing is banks are the one to know this definition, so let them decide whats valid number and what is not. You can do some basic validation which should be verry loose.Audile
C
22

Read this article: link

It's about generating credit card numbers, but it helps figuring out if the card is valid.

These are the rules that links credit card companies to their credit card numbers:

Visa = 4XXX - XXXX - XXXX - XXXX
MasterCard = 5[1-5]XX - XXXX - XXXX - XXXX
Discover = 6011 - XXXX - XXXX - XXXX
Amex = 3[4,7]X - XXXX - XXXX - XXXX
Diners = 3[0,6,8] - XXXX - XXXX - XXXX
Any Bankcard = 5610 - XXXX - XXXX - XXXX
JCB =  [3088|3096|3112|3158|3337|3528] - XXXX - XXXX - XXXX
Enroute = [2014|2149] - XXXX - XXXX - XXX
Switch = [4903|4911|4936|5641|6333|6759|6334|6767] - XXXX - XXXX - XXXX
Cognoscenti answered 6/10, 2012 at 17:40 Comment(5)
actually, I've got that part nailed. I was talking about Card/Bank Account Name/Number validationGuglielmo
There's only account holder's name stored in the magnetic string. The bank account number the card is related with, can't be known using the credit card alone. That information is discreet. @GuglielmoCognoscenti
Yeah, I meant bank account in general i.e. if i were to validate a bank account number (not necessarily linked to a card)Guglielmo
Bankcard was withdrawn in 2006. If you must store historical data, OK, but don't accept 5610... for any new transactions.Yuki
There's some good information here, but also a critical piece of misinformation. Not all cards have 16 digits. In particular, not even all Visa cards have 16 digits. In Europe, ordinary Visa cards can have fewer than 16 digits, and the V Pay range can have more than 16. As far as validating numbers of digits goes, you should only be applying the 19 digit limit from ISO standard 7812-1.Aylmer

© 2022 - 2024 — McMap. All rights reserved.