Reply To: Validador Javascript

Home Forums Quform WordPress Validador Javascript Reply To: Validador Javascript

#33202
johnpaes
Participant

Hello, could you help me to use this “Validator” on Custom JavaScript field?

<script language=”javascript”>
function VerificaCPF () {
if (vercpf(document.frmcpf.cpf.value))
{document.frmcpf.submit();}else
{errors=”1″;if (errors) alert(‘CPF NÃO VÁLIDO’);
document.retorno = (errors == ”);}}
function vercpf (cpf)
{if (cpf.length != 11 || cpf == “000.00.0000-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;

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