function verificarCPF(){
var CPF = document.getElementById("cpf").value;
if(CPF < 0 || CPF.toString().length != 11){
document.getElementById("cpfErro").innerHTML = " CPF inválido!";
return false;
}
//var num1 = CPF[9];
//var num2 = CPF[10];
var Soma = 0;
var Resto = 0;
for(i=1; i<=9; i++) {
Soma = Soma + parseInt(CPF.substring(i-1, i)) * (11 - i);
}
Resto = (Soma * 10) % 11;
if((Resto == 10) || (Resto == 11)) Resto = 0;
if(Resto != parseInt(CPF.substring(9, 10)) ) {
document.getElementById("cpfErro").innerHTML = " CPF inválido!";
return false;
}
Soma = 0;
for(i = 1; i <= 10; i++)
{
Soma = Soma + parseInt(CPF.substring(i-1, i)) * (12 - i);
}
Resto = (Soma * 10) % 11;
if ((Resto == 10) || (Resto == 11)) Resto = 0;
if (Resto != parseInt(CPF.substring(10, 11) ) ) {
document.getElementById("cpfErro").innerHTML = " CPF inválido!";
return false;
}
return true;
}