
function isCPF(cpf)
{var result="";var OK=false;var temp=justNumbersStr(trim(cpf));if(onlySameNumber(temp))
return false;if(temp.length>10)
{var work=temp.substring(0,(temp.length)-2)
var resto=getVerificationDigit(work);OK=(resto==parseInt(temp.charAt((temp.length)-2)));if(OK)
{work=work+resto;resto=getVerificationDigit(work);OK=(resto==parseInt(temp.charAt((temp.length)-1)));}}
return(OK)}
function getVerificationDigit(S)
{var invertido=invertStr(justNumbersStr(S));var soma=0;for(var i=0;i<invertido.length;i++){soma=soma+(i+2)*parseInt(invertido.charAt(i))}
soma*=10;return((soma%11)%10)}