Credit Card Validation Solution: validate numbers using PHP, Perl, Java or Visual Basic

The Credit Card Validation Solution is a set of open source scripts that ensure credit card information is keyed in correctly.

It's presently available for download in three languages: Java, PHP and Perl. The old Visual Basic version is about to undergo overhaul, which we hope to complete shortly.

The Credit Card Validation Solution checks that the card number length is correct, the first four digits are within accepted ranges, the number passes the Mod 10 / Luhn checksum algorithm and that you accept the given type of card. Expiration date validation is optional. They also tell you which kind of card is being used based on the number.

Error message text is internationalized. Current translations include English, French (Français), German (Deutsche) and Spanish (Español). Others can be easily added.

Types of cards handled:

Just to be clear, this process does not check with banks or credit card companies to see if the card number given is actually associated with a good account. It just checks to see if the number matches the expected format.

Change Log

Feel free to read the log of changes made.

Inline Documentation

The programs are thoroughly documented in the code itself via docblock comments. They can be rendered using phpDocumentor or Javadoc.


Credit Card Validation Solution is a trademark of The Analysis and Solutions Company.