Reply To: Validador Javascript

Home Forums Quform WordPress Validador Javascript Reply To: Validador Javascript

#33207
johnpaes
Participant

Hello Ally,
Thank you very much for your quick reply.
Sorry, part of the code was missing. I also didn’t comment that in this same field have an active mask working with this code:

jQuery(function ($) {
if ($.fn.mask) {
$(‘.quform-field-1_6’).mask(‘000.000.000-00’);
}
});

This mask works perfectly.

Here we have the complete “validator” code.
———–

function validarCPF(cpf) {
cpf = cpf.replace(/[^\d]+/g,”);
if(cpf == ”) return false;
if (cpf.length != 11 ||
cpf == “000.000.000-00” ||
cpf == “111.111.111-11” ||
cpf == “222.222.222-22” ||
cpf == “333.333.333-33” ||
cpf == “444.444.444-44” ||
cpf == “555.555.555-55” ||
cpf == “666.666.666-66” ||
cpf == “777.777.777-77” ||
cpf == “888.888.888-88” ||
cpf == “999.999.999-99”)
return false;
add = 0;
for (i=0; i < 9; i ++)
add += parseInt(cpf.charAt(i)) * (10 – i);
rev = 11 – (add % 11);
if (rev == 10 || rev == 11)
rev = 0;
if (rev != parseInt(cpf.charAt(9)))
return false;
add = 0;
for (i = 0; i < 10; i ++)
add += parseInt(cpf.charAt(i)) * (11 – i);
rev = 11 – (add % 11);
if (rev == 10 || rev == 11)
rev = 0;
if (rev != parseInt(cpf.charAt(10)))
return false;
return true;
}

—————————–
Thank you very much.
Best Regards,
John.

Be inspired. © 2020 ThemeCatcher Ltd. 20-22 Wenlock Road, London, England, N1 7GU | Company No. 08120384 | Built with React | Privacy Policy