Created
February 18, 2016 11:34
-
-
Save MaslennikovYV/55d5f4c90a23699130c9 to your computer and use it in GitHub Desktop.
Валидация ИНН (Идентификационный Номер Налогоплательщика) для jQuery Validation http://jqueryvalidation.org/
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$.validator.addMethod("inn", function (value, element) { | |
var multipliers = [3, 7, 2, 4, 10, 3, 5, 9, 4, 6, 8], | |
inn = value.split(''), i, j, ch = [0, 0, 0]; | |
for (i = 0; i < 12; i++) | |
for (j = 0; j < 3; j++) | |
if (multipliers[i + j]) | |
ch[j] = ch[j] + inn[i] * multipliers[i + j]; | |
if (inn.length == 10) | |
return inn[9] == ch[2] % 11 % 10; | |
else if (inn.length == 12) | |
return inn[10] == ch[1] % 11 % 10 && inn[11] == ch[0] % 11 % 10; | |
else | |
return !value; | |
}, "Ошибка при наборе ИНН"); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
огонь)