How to Validate Visa Card Numbers
Visa card numbers, as well as most other credit card numbers, can be validated using the Luhn algorithm (also known as the Luhn formula or the “mod 10” or “modulus 10” algorithm).
It is a very simple procedure, which verifies the card number in the following fashion:
- Double the value of the card number’s every odd digit. If the resulting sum of each doubling operation is greater than 9 (for example, 6 x 2 = 12), then add the digits of the sum (e.g., 12: 1 + 2 = 3 or 16: 1 + 6 = 7).
- Add up all the resulting digits, including the ones you did not multiply by two.
- If the total you received ends in 0, the card number is valid according to the Luhn algorithm; otherwise it is not valid.
For example, let’s validate the following Visa number: “4024007191315703”. Here is what we get when we follow the three-step process I’ve just described:
The end result — 50 — ends in 0, which means that our number passes the Luhn formula test.
Of course, the card number’s validity does not preclude the possibility that the card may still be counterfeit, so you will need to follow the best card acceptance practices I’ve outlined below.