Skip to content

Instantly share code, notes, and snippets.

@MaslennikovYV
Created February 18, 2016 11:34
Show Gist options
  • Save MaslennikovYV/55d5f4c90a23699130c9 to your computer and use it in GitHub Desktop.
Save MaslennikovYV/55d5f4c90a23699130c9 to your computer and use it in GitHub Desktop.
Валидация ИНН (Идентификационный Номер Налогоплательщика) для jQuery Validation http://jqueryvalidation.org/
$.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;
}, "Ошибка при наборе ИНН");
@ssk181
Copy link

ssk181 commented Feb 18, 2016

огонь)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment