Credit Card Checker

January 24, 2017

Credit Card Number Checker Using Regex

So this is primarily done to understand how Regex actually works. With Credit Card numbers,verification of the credit card number is done by the Luhn Algorithm. Wikipedia has a better explanation than I can give, but the gist is that the checksum doubles every other number in account number and then adding it together. Once the total is calculated and modulo 10 equals zero, we have our verified account number.

In regards to the regex, it is here:

^[4][0-9]{15}$|^[4][0-9]{12}$|^[5][1-5][0-9]{14}|^[3][(4|7)][0-9]{13}

In short essence, this regex will parse the full 16 digit long credit card number, and verify the values that enter the text field.

creditCard