Source Code for Me (s-c.me)

Allows you to paste souce code to blogs! Adapted for Twitter! Here is Search Form in case you missed your code.
Code:
Selected Language:
Show Linenumbers:
Short link for Twitter:
HTML:

HTML view:

Copy Source | Copy HTML
  1. // Функция для проверки правильности ИНН
  2. function is_valid_inn(i)
  3. {
  4.     i += '';
  5.     if ( i.match(/\D/) ) return false;
  6.     var inn = i.match(/(\d)/g);
  7.     if ( inn.length == 10 )
  8.     {
  9.         return inn[9] == String(((
  10.             2*inn[ 0] + 4*inn[1] + 10*inn[2] +
  11.             3*inn[3] + 5*inn[4] + 9*inn[5] +
  12.             4*inn[6] + 6*inn[7] + 8*inn[8]
  13.         ) % 11) % 10);
  14.     }
  15.     else if ( inn.length == 12 )
  16.     {
  17.         return inn[10] == String(((
  18.              7*inn[ 0] + 2*inn[1] + 4*inn[2] +
  19.             10*inn[3] + 3*inn[4] + 5*inn[5] +
  20.              9*inn[6] + 4*inn[7] + 6*inn[8] +
  21.              8*inn[9]
  22.         ) % 11) % 10) && inn[11] == String(((
  23.             3*inn[ 0] + 7*inn[1] + 2*inn[2] +
  24.             4*inn[3] + 10*inn[4] + 3*inn[5] +
  25.             5*inn[6] + 9*inn[7] + 4*inn[8] +
  26.             6*inn[9] + 8*inn[10]
  27.         ) % 11) % 10);
  28.     }
  29.     return false;
  30. }​




Based on Manoli.Net's CodeFormatter. Made by Topbot (c) 2008-2017