Skip to content

Commit

Permalink
Merge pull request #379 from nilsonLazarin/gabriel
Browse files Browse the repository at this point in the history
Alterações realizadas no sistema entre os dias 09/05 e 20/05/2024
  • Loading branch information
nilsonLazarin authored May 22, 2024
2 parents 8a1a0d5 + 3a45562 commit 9390a9a
Show file tree
Hide file tree
Showing 25 changed files with 2,125 additions and 2,156 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 9390a9a

Please sign in to comment.