Skip to content

Instantly share code, notes, and snippets.

@kyriakidischronis
Forked from tdoumas/amka-validator.js
Last active August 29, 2015 14:10
Show Gist options
  • Save kyriakidischronis/a3a750ebde9af7399cff to your computer and use it in GitHub Desktop.
Save kyriakidischronis/a3a750ebde9af7399cff to your computer and use it in GitHub Desktop.
// Greek Social Security Number Validation (AMKA)
// Αλγόριθμος ορθότητας ΑΜΚΑ
function validateAMKA(amka) {
if (!amka.match(/^\d{11}$/) || amka == '00000000000')
return false;
var iSum = 0;
for (var i = 1; i <= amka.length; i++) {
var iDigit = parseInt(amka.charAt(i - 1), 10);
if (i % 2 === 0) {
iDigit *= 2;
if (iDigit > 9) {
iDigit -= 9;
}
}
iSum += iDigit;
}
return (iSum % 10 === 0);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment