Created
December 9, 2013 16:44
-
-
Save tdoumas/7875550 to your computer and use it in GitHub Desktop.
Αλγόριθμος ορθότητας ΑΦΜ
Greek Tax Registration Number Validation (AFM)
This file contains 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 Tax Registration Number Validation (AFM) | |
// Αλγόριθμος ορθότητας ΑΦΜ | |
function validateAFM(afm) { | |
if (!afm.match(/^\d{9}$/) || afm == '000000000') | |
return false; | |
var m = 1, sum = 0; | |
for (var i = 7; i >= 0; i--) { | |
m *= 2; | |
sum += afm.charAt(i) * m; | |
} | |
return sum % 11 % 10 == afm.charAt(8); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment