<pedrocorreia.net ⁄>
 

<Credit Card Validation ⁄ >




clicks: 3401 3401 2007-04-03 2007-04-03 goto programacao myNews programacao  Bookmark This Bookmark This


Many companies sell products over the internet. When doing that, getting credit card input over the internet becomes important. And then validating those credit card numbers becomes important. Here is a combination of regular expression validation and standard JavaScript to check to see if a credit card number is a valid number. The code below will do that validation. However, note that this doesn't check to see if the specific credit card number has really been issued by the bank, or if the owner of the credit card has enough credit available, etc. You'll still need to go through your merchant account software to validate all that information, but this initial check assures that the credit card number itself is one that could have been issued.

This code handles the most popular types of credit card: Visa, Master Card, Discover, American Express, and Diner's Club. Each of these cards start out with a different prefix and card number length. This information is used for the regular expression validation. After the card number has the right prefix and is the correct length, a "mod 10" validation is performed on the credit card number. This code is a bit strange and needs some explanation. Cards with an even number of digits go through differently than cards with an odd number of digits (American Express). Every other digit, starting with the second digit (first digit for American Express) is added together. Then a second pass is made, again with every other digit, starting this time with the first digit (second digit for American Express). During this second pass, each digit is multipled by 2. If the digit multiplied by 2 is greater than or equal to 10, the total minus 9 is added to the original sum from the first pass. If the digit multiplied by 2 is less than 10, that total is added to the original sum from the first pass. After the two passes, the total should be evenly divisible by 10. This is the check that the JavaScript code goes through to validate the credit card.



este é só um excerto do artigo, para aceder ao artigo completo, clique no link em baixo:
this is just a small excerpt from the article, to access the full article please click in the link below:

http://www.breakingpar.com/bkp/home.nsf/0/87256B280015193F87256CC70060...




Subscribe News RSS  Subscribe News Updates by E-mail





myNews <myNews show="rand" cat="programacao" ⁄>

RouterJs: easy routing for your ajax Web applications new ...

RouterJs is a simple router for your ajax web apps. It's build upon History.js which means that Rout (...)

clicks: 16497 16497 2012-05-14 2012-05-14 goto url (new window) haithembelhaj.g... goto myNews programacao


Backbone computed properties new ...

This gist shows one way to implement read- and write-enabled computed properties on a Backbone Model (...)

clicks: 16343 16343 2012-05-13 2012-05-13 goto url (new window) https://gist.gi... goto myNews programacao


Create Instagram Filters With PHP new ...

In this tutorial, I'll demonstrate how to create vintage (just like Instagram does) photos with PHP (...)

clicks: 16039 16039 2012-05-12 2012-05-12 goto url (new window) net.tutsplus.co... goto myNews programacao


HTML5 jQuery Paint Plugin new ...

Websanova Paint is a HTML5 canvas based jQuery plugin. It allows you to free paint on a canvas area (...)

clicks: 27132 27132 2012-05-12 2012-05-12 goto url (new window) websanova.com/t... goto myNews programacao


Android Query new ...

Android-Query (AQuery) is a light-weight library for doing asynchronous tasks and manipulating UI el (...)

clicks: 16533 16533 2012-05-12 2012-05-12 goto url (new window) code.google.com... goto myNews programacao


Real-time Applications With Node.js and Socket.IO new ...

Hey everyone! Sorry about the long pause since the last blog post, life has been quite hectic for th (...)

clicks: 16410 16410 2012-05-11 2012-05-11 goto url (new window) codingcookies.c... goto myNews programacao


Sass vs. LESS vs. Stylus: Preprocessor Shootout new ...

CSS3 preprocessors are languages written for the sole purpose of adding cool, inventive features to (...)

clicks: 15738 15738 2012-05-11 2012-05-11 goto url (new window) net.tutsplus.co... goto myNews programacao


15 Handpicked jQuery Drop Down Menus Tutorials new ...

Here we are presenting another brilliant collection of 15 jQuery navigation menu that you can downlo (...)

clicks: 15451 15451 2012-05-10 2012-05-10 goto url (new window) smashingapps.co... goto myNews programacao