...

View Full Version : Credit Card Validation



newname
03-22-2004, 03:30 PM
I was wondering if credit card validation was done by communication with a card company, or if it could be done with a script. This would be implemented on a secure server, of course. If it can be done with a script, can someone tell me how to get started?

Peter

Nightfire
03-22-2004, 03:39 PM
Best off using a third party when involving credit cards. Use something like www.paysystems.com

jessegavin
03-22-2004, 05:25 PM
This works for me. It will validate whether or not the Credit Card Number is a possible credit card number. There are certain mathmatical rules (which I will not get into now, [because I don't know them]) which determine possible valid numbers.

This has always worked for me.


function isValidCC(n) {
re = /^((4\d{3})|(5[1-5]\d{2})|(6011))-?\d{4}-?\d{4}-?\d{4}|3[4,7]\d{13}$/
return = re.test(n);
}

Usage:
if (isValidCC("1234569878956454")) {
alert("YAY, it is valid");
} else {
alert("Blast, it is invalid!");
}



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum