The goal would be to validate on the browser side prior to sending the data back to the server.
A google search for "javascript credit card validation" shows multiple existing JavaScripts that are available, as well as references to others from StackOverflow posts. The JavaScript by Powel Decowski at http://jquerycreditcardvalidator.com/ has a nice simple interface and incorporates the luhn checksum
TIA