Quantcast
Channel: Adobe Community: Message List - PDF Forms
Viewing all articles
Browse latest Browse all 57214

How to adapt this code for adobe (CPF BRAZIL)

$
0
0

Hi,

How to adapt this code for adobe?

 

functionvalidarCPF(cpf) {

 

    cpf = cpf.replace(/[^\d]+/g,'');

 

    if(cpf == '') returnfalse;

 

    // Elimina CPFs invalidos conhecidos

    if(cpf.length != 11 ||

        cpf == "00000000000"||

        cpf == "11111111111"||

        cpf == "22222222222"||

        cpf == "33333333333"||

        cpf == "44444444444"||

        cpf == "55555555555"||

        cpf == "66666666666"||

        cpf == "77777777777"||

        cpf == "88888888888"||

        cpf == "99999999999")

        returnfalse;

   

    // Valida 1o digito

    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)))

        returnfalse;

   

    // Valida 2o digito

    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)))

        returnfalse;

       

    returntrue;

  

}

 

Or this: http://www.rafaelwendel.com/2011/06/funcao-javascript-para-validar-cpf /

 

Thanks!


Viewing all articles
Browse latest Browse all 57214

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>