This is commonly used in Sweden for evaluating "Personnummer" (social security
number).
function modul_10(checkValue) {
faktor = 2;
sum = 0;
check = true;
checkStr = checkValue;
checkDigit = parseInt(checkStr.charAt(checkStr.length-1));
for (index = checkStr.length-1; index > 0; --index) {
produkt = checkStr.substring (index-1, index) * faktor;
if ( produkt > 9 ) {
produkt %= 10;
produkt += 1;
}
sum = sum + produkt;
faktor = 3 - faktor;
}
cc = ((1000 - sum) % 10);
if ( checkDigit != cc ) {
check = false;
}
return check;
}
Requires Free Membership to View
Register today to access targeted resources from our editorial writers and independent industry experts focused on Lotus Domino, Notes, Workplace and other related technologies.
This was first published in November 2000