Skip to content

Commit

Permalink
Merge pull request #590 from nilsonLazarin/master
Browse files Browse the repository at this point in the history
updating pre-release
  • Loading branch information
nilsonLazarin authored Jun 6, 2024
2 parents 2b5b6b9 + 05a3ef9 commit 58fa252
Show file tree
Hide file tree
Showing 53 changed files with 4,299 additions and 4,055 deletions.
21 changes: 21 additions & 0 deletions Functions/testaCPF.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
function testaCPF(strCPF) {
var strCPF = strCPF.replace(/[^\d]+/g, ''); // Limpa a string do CPF removendo espaços em branco e caracteres especiais.
var Soma;
var Resto;
Soma = 0;
if (strCPF == "00000000000") return false;

for (i = 1; i <= 9; i++) Soma = Soma + parseInt(strCPF.substring(i - 1, i)) * (11 - i);
Resto = (Soma * 10) % 11;

if ((Resto == 10) || (Resto == 11)) Resto = 0;
if (Resto != parseInt(strCPF.substring(9, 10))) return false;

Soma = 0;
for (i = 1; i <= 10; i++) Soma = Soma + parseInt(strCPF.substring(i - 1, i)) * (12 - i);
Resto = (Soma * 10) % 11;

if ((Resto == 10) || (Resto == 11)) Resto = 0;
if (Resto != parseInt(strCPF.substring(10, 11))) return false;
return true;
}
Loading

0 comments on commit 58fa252

Please sign in to comment.