Properly Validate Credit Card Numbers

Category:
Dates and Math
Type:
Snippets
Difficulty:
Beginning
Author:
Anonymous

Version Compatibility:

More information:
To make sure a credit card number is a valid card number, there is a relatively basic math process to apply. Starting from the end, if the positin of the digit is odd, you add its value to 2 times the digit that precedes it. If the position of the digit is even, you add double its value to the number that follows it. The resulting value should be a multiple of 10, which can easily be checked by using the MOD() function, expecting a result of zero.

Instructions: Click the link below to download the code. Select 'Save' from the IE popup dialog. Once downloaded, open the .zip file from your local drive using WinZip or a comparable program to view the contents.

Download cardvalidator.zip