Skip to content

Instantly share code, notes, and snippets.

@paligiannis
Forked from tdoumas/afm-validator.js
Created February 11, 2020 11:36
Show Gist options
  • Select an option

  • Save paligiannis/d0cc3c6aa20e5e40c9d15d8f6b86c149 to your computer and use it in GitHub Desktop.

Select an option

Save paligiannis/d0cc3c6aa20e5e40c9d15d8f6b86c149 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