-
-
Save kyriakidischronis/a3a750ebde9af7399cff to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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