-1
I’m making a system that needs to validate the Brazilian field Cpf but if Cpf is foreign does not need to validate the validation part of Cpf is OK, but how would I put in the function to disregard foreign Cpf.
follows the code:
//valida o CPF
function verificarCPF(c){
var i;
s = c;
var c = s.substr(0,9);
var dv = s.substr(9,2);
var d1 = 0;
var v = false;
for (i = 0; i < 9; i++){
d1 += c.charAt(i)*(10-i);
}
if (d1 == 0){
alert("CPF Inválido")
v = true;
return false;
}
d1 = 11 - (d1 % 11);
if (d1 > 9) d1 = 0;
if (dv.charAt(0) != d1){
alert("CPF Inválido")
v = true;
return false;
}
d1 *= 2;
for (i = 0; i < 9; i++){
d1 += c.charAt(i)*(11-i);
}
d1 = 11 - (d1 % 11);
if (d1 > 9) d1 = 0;
if (dv.charAt(1) != d1){
alert("CPF Inválido")
v = true;
return false;
}
if (!v) {
//alert(c + "nCPF Válido")
}
}
What is a foreign number?
– fernandosavio
CPF is a Brazilian document. Therefore, I believe that all CPF should be validated if inserted. Of course, if the foreign CPF you are referring to is that CPF that is made for foreign people who come to Brazil.
– Rafael Barros
Foreign CPF is different?
– Sam
The question was half vacant for example you want to know a foreigner who has CPF (Brazilian document), Or a foreign document like the social service number in the USA that would be the equivalent of our CPF If it is the CPF there is as the last digit before the check digit is referring to the tax region of Brazil where the CPF was issued
– Fernando Moura
Foreign CPF is equal to Brazilian CPF. It has the same standard of numbers.
– Rafael Barros