Credit cards are somewhat self-verifying and self-identifying:
Number of digits varies by Issuer with AMEX and Diner's being 15 digit and VISA, MC, Discover and BankCard being 16 (maybe). The test below requires that the number be entered without blanks or dashes. Accepting more free-form input is left as an exercise for the reader.