Skip to content

Instantly share code, notes, and snippets.

@bandicsongor
Created June 14, 2013 14:27
Show Gist options
  • Save bandicsongor/5782245 to your computer and use it in GitHub Desktop.
Save bandicsongor/5782245 to your computer and use it in GitHub Desktop.
Validare cnp, cnp validation, CNP validalas
function valideazacnp(cnp) {
var constanta= "279146358279";
if(cnp.length!=13) return false;
var suma=0;
for(i=0; i<constanta.length; i++) {
suma=suma+cnp.charAt(i)*constanta.charAt(i);
}
var rest=suma%11;
if((rest <10 && rest == cnp.charAt(12)) || (rest == 10 && cnp.charAt(12) == 1)) {
return(true);
}
else {
return(false);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment