validating credit cards

Questions, tips and tricks and techniques for scripting in Servoy

validating credit cards

Postby Neale » Wed Jul 23, 2003 11:51 pm

Before I go re-inventing wheels, are there any available methods or JS functions to validate a credit-card number (i.e. compute the check-digit)?

Thanks,
Neale.
Neale
 
Posts: 230
Joined: Thu May 15, 2003 6:29 am
Location: Australia

Postby maarten » Thu Jul 24, 2003 11:13 am

Hi Neale,

Here's a link to a simple creditcard validation in javascript.
It's HTML orientated, but you can easily copy paste the if statements into your own script.
http://www.shu.ac.uk/schools/cms/teaching/rh1/elearning/creditcard/credit_card_validation.htm

You can also use http://www.google.com and search for eg: "javascript creditcard validation", giving you loads of examples!
(I'd like to encourage everyone who finds interesting (javascript)code on the net, to place a link on the forum... :) thanks )
Maarten Berkenbosch
User avatar
maarten
 
Posts: 797
Joined: Wed Apr 23, 2003 10:52 pm
Location: Amersfoort, Netherlands

Postby Neale » Fri Jul 25, 2003 1:13 am

Thanks for the feedback.

As you say, there are many available if only I had searched. Searching via Google for 'javascript (creditcard OR "credit card") validation' returned many interesting possibilities, including: http://www.breakingpar.com/bkp/home.nsf ... C70060A01B

That's nice concise code and pretty close to what I'm looking for, except that:

1) It needs to accomodate more cards types (starting with the Aussie "BankCard").
2) I suspect there's a bug in that it allows card#s with dashes but doesn't appear to account for these when computing the checksum.

Both of those should be fairly trivial to fix.

There's another interesting example at http://javascript.about.com/library/scr ... cvalid.htm and no doubt many more elsewhere.

IIRC, there was some discussion here about how to create a global method which can be called as a function from various form methods. Any pointers here?

Thanks,
Neale.
Neale
 
Posts: 230
Joined: Thu May 15, 2003 6:29 am
Location: Australia


Return to Methods

Who is online

Users browsing this forum: No registered users and 13 guests