Forum Replies Created
- AuthorPosts
johnpaes
ParticipantHello Ally,
I managed to set the validator following your instructions. The problem is that I can send the form even getting the error message in this field. Is it possible to fix it?Thank you very much!
Best Regards,
John.johnpaes
ParticipantHello Ally,
Do you think this can work? Can i have hope?Thank you very much.
Best Regards,
John.johnpaes
ParticipantHello 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.johnpaes
ParticipantHello, 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.- AuthorPosts