
Theis is an example of a small JavaScript function, luhn_check(), which checks whether a number is a valid based on the Luhn algorithm. One common example of use is with credit and debit card numbers. This function may be used to check for valid credit card numbers, however additional checks may be desired, such as card prefix and length checks.
Test number: 4111111111111111 (four followed by fifteen ones)
This is just an example page. You can get the code or just view the source of this page.