for work, research and validate the ILS using the Modulo 11 algorithm that uses the SAT in Guatemala but looking at google code only found in half VBScript and one in C # but wanted it in Javascript as I found an easy way to do it.
The algorithm consists of the following, we have the following NIT: 42932-5
Then multiply:
4 * 6 = 24
2 * 5 = 10
9 * 4 = 36
3 * 3 = 9
2 * 2 = 4
Briefly multiply each letter in your position. What they do not multiply the last position that will serve us later.
83 The result gives us apply the modulo 11 as follows:
83 mod 11 = 6
then the result is the following:
11 to 6 = 5
This result should be identical the last digit after the script that is called a check digit, and so we notice if an ILS is valid.
A cotinuacion I put the algorithm done in JavaScript:
ValidarNITMod11 function () {var
pos = txtNIT.value.indexOf ("-");
var = txtNIT correlative. value.substring (0, pos);
var txtNIT.value.substring digitoverificador = (pos + 1, txtNIT.value.length)
var factor = correlativo.length + 1;
var value = 0;
for (i = 0; var i < style="font-style: italic; font-weight: bold;"> residue = Value% 11;
var result = 11 - remainder;
if (result == 10) {if
(digitoverificador.toUpperCase () == "K")
{alert ("The NIT is valid ");
return true;}
} else {
if (result == digitoverificador)
{alert (" The NIT is valid ");
return true;}
} alert ("The NIT is invalid");
return false;}
txtNIT The variable is the id type of text input.
View Sample
Au \u200b\u200brevoir à tous
....