View Full Version : Credit Card Validation

08-18-2005, 10:47 AM
Does anyone know of any credit card validation scripts that include validation for switch/maestro?
I found a great script but its very americanised so no good for my purposes :(

08-18-2005, 03:07 PM
I may not be helping since I don't know that switch/maestro is but this is the only one I've used in the past...


08-18-2005, 03:43 PM
Thats similar to the one I've found (but in asp not javascript) but it doesnt handle switch cards. I think I might have got it sussed with a little regex... I'm pretty sure all switch numbers start 67

that handles visa, mastercard, switch, solo, and amex I think

08-21-2005, 06:38 AM
I do not know of any good prewritten/free scripts available on the web. Maybe some digging on google can produce some results. However, if you want to write your own... read below.

Are you just checking to see if the value is numeric and if the number's prefix is assigned to a specific card type? (that appears to be what the regex is doing). However, something more robust may be used if you implement validation using the Luhn formula (mod 10). Not sure about switch/solo but visa/mastercard/amex and most other credit card numbers can be checked in this fashion.

Luhn Formula -- http://www.webopedia.com/TERM/L/Luhn_formula.html

Also, it may be good to mention that before you pass the number to the above mentioned check it will be wise to check the length and make sure it is correct for the card type trying to be submitted.