Credit Card Check Validation Routine
CSGNetwork Custom Search
Top Free Apps
Right click this window and select "view source" in order to copy the source for this script.
Credit Card Number:
Credit card numbers are all numeric and have fixed lengths (13 digits for Diners Club, 15 for American Express, and 16 digits for all the others). Some other credit card numbering systems vary. The card numbers also contain what is called a "check digit" to help ensure that if you transpose digits in the entered credit card number that you are not accidentally quoting a number belonging to someone else. This means that only certain number combinations are valid.
Enter something into the above credit card validation test field; then click the validate button. An alert box will display to tell you whether the number entered COULD be a valid credit card number. You can apply this validation to your own credit card number fields by calling the following validation routine from the point in your code you wish to perform the validation. Pass the field to be validated (non-numerics in the field will be ignored). The function will return true if the number supplied is the correct length and COULD be a credit card number; otherwise, it will return false if it is definitely not a valid card number.
There are limitations. This routine only tests if the number entered is the right length to be a credit card number and contains the correct check digit. Numbers accepted by this code COULD be valid credit card numbers but may not actually correspond to a card that has been issued. Cards rejected by the routine are definitely not valid. No cards are tested for credit capability in this routine. To properly validate credit card numbers requires server side processing but this code will help you to reject many invalid numbers before the server side routine needs to be called. Note also that this script handles preliminary validation only and does not contain any code relating to security. You need to have appropriate security measures (including possible encryption) in place if you are going to ask for people to enter their credit card numbers on your site.
Registered® Trademark™ and CopyrightŠ 1973 -
CSG, Computer Support Group, Inc. and CSGNetwork.Com
All Rights Reserved