<script src=”https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js”></script>
<script>
$(document).ready(function() {
$(“#id_submitbutton”).focus(function(){
var strCPF = document.getElementById(“id_profile_field_CPF”);
function TestaCPF(strCPF) {
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;
}
var cpf = strCPF.value;
var valida_cpf = (TestaCPF(cpf));
if(valida_cpf == false){
alert(“CPF Invalido”);
//window.location.href = “https://ava.fundacaocasa.sp.gov.br/login/signup.php”;
document.getElementById(“id_profile_field_CPF”).value = “”;
}
if(valida_cpf == true){
//alert(“CPF Valido”);
//alert(cpf);
}
});
});
</script>