Skip to content

Instantly share code, notes, and snippets.

@tdoumas
Created December 9, 2013 16:44
Show Gist options
  • Save tdoumas/7875550 to your computer and use it in GitHub Desktop.
Save tdoumas/7875550 to your computer and use it in GitHub Desktop.
Αλγόριθμος ορθότητας ΑΦΜ Greek Tax Registration Number Validation (AFM)
// 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