function checkCode(card){ if (/^\d{17}[\dxX]$/.test(card)) { var a = [7,9,10,5,8,4,2,1,6,3,7,9,10,5,8,4,2]; var valide = [1,0,‘X‘,9,8,7,6,5,4,3,2]; var s = 0; for (var i = 0; i < card.length - 1; i++) { s += card.charAt(i) * a[i]; } var mod = s % 11; if (valide[mod] != card.charAt(17).toUpperCase()) { return false; } else { return true; } } return false; }
时间: 2024-10-16 06:21:38