What does it not do?
Please note that these routines only determine whether a credit card is
valid. A valid calid credit card number does not imply that it is a credit
card that has actually been issued or (if it has been issued) is in good
standing.
To actually see if a valid credit card number has been issued and is in good standing you would have to use a Credit Card Merchant Service. Credit card merchant services are beyond the scope of this document.
Copyright
These routines are licensed for usage and redistribution under The GNU General Public License
How do I use it?
You could use these routines along with your FORMs to validate credit
card numbers. By doing this number validation via JavaScript you can
save unneccesary calls on your CGI scripts.
To use these routines you would have to download the routines. You would then have to plug in these routines between the <HEAD> and </HEAD> of your HTML file containing the form. The routines provide the following functions -
if (typeOfCard(document.ccForm.ccard.value == "AMEX") {
alert("You have entered the number of an American Express card.\nWe do not acept this card at the moment.\nPlease try again with a Matercard or Visa card.");
}
if (! isValidCreditCard(document.ccForm.ccard.value) {
alert("You have entered an invalid credit card number.\nPlease try again after entering a valid credit card number");
}
Feedback
If you use this code, please email
me your comments and suggestions. Since this is purely voluntary work,
any encouragement I get goes a long way in motivating me to keep working on
these.