Restricting credit card validator to include length check. Closes gh-772

Without this, '41111' is considered a valid credit card number.
This commit is contained in:
Andrew Ray
2013-06-06 17:40:08 -07:00
committed by Jörn Zaefferer
parent 4bf813b751
commit f5f47c5c66
2 changed files with 9 additions and 2 deletions

View File

@@ -1057,6 +1057,12 @@ $.extend($.validator, {
value = value.replace(/\D/g, "");
// Basing min and max length on
// http://developer.ean.com/general_info/Valid_Credit_Card_Types
if ( value.length < 13 || value.length > 19 ) {
return false;
}
for (var n = value.length - 1; n >= 0; n--) {
var cDigit = value.charAt(n);
nDigit = parseInt(cDigit, 10);