We all know that 42 is the answer to everything, but it’s news to me that it is a valid credit card number.
Try entering ’42’ or ‘42176’ into this jQuery Validation testing page and click OK.
What’s going on? I thought this was supposed to be the de-facto validation library. Even Microsoft is using it now, but it thinks ’42’ and ‘42176’ are valid credit card numbers?! It’s not even doing a length check. Surely I’m not responsible for adding a length check too? It’s called ‘creditcard’ validator and not ‘luhn’ validator.
Edit: hitchhiker humor aside – how would I go about patching the validation plugin to check length. is that easy?
This is probably because this validator merely checks that the number supplied satisfies the LUHN-10 algorithm (which 42 satisfies since 4*2 + 2 = 10 which is 0 modulo 10).
A better validator should maybe check for a minimal number of digits.
I’m not sure this corresponds to the very latest code from jQuery, but I found the snippet associated with credit card validation:
… and as you see this merely check that all characters are digits and that LUHN-10 is satisfied, without any attention to a minial length.