Verifying Well-Formed Credit Card Numbers

The only way to completely verify the validity of a credit card number is through a Web server specifically set up to handle credit card transactions. However, you can use JavaScript to apply some checks at the client-side that enable you to determine whether the number is well formed. A well-formed number is one that could be a valid number for that type of credit card. Passing the test for being well formed does not mean that the number is from a good credit card; failing the test, however, does mean that the number can't be from a good card.

You can apply two easy tests using JavaScript at the client-side. These tests enable you to determine whether a credit card number for a given card type is well ...

Get Platinum Edition Using XHTML™, XML, and Java™ 2 now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.