Formatação de CNPJ
Publicado por Marcelo R. Castelo Branco 13/04/2005
[ Hits: 11.253 ]
JavaScript para criar máscara de CNPJ. Simples e funcional.
<script language="JavaScript"> function FormataCNPJ(Campo, teclapres){ var tecla = teclapres.keyCode; var vr = new String(Campo.value); vr = vr.replace(".", ""); vr = vr.replace(".", ""); vr = vr.replace("/", ""); vr = vr.replace("-", ""); tam = vr.length + 1 ; if (tecla != 9 && tecla != 8){ if (tam > 2 && tam < 6) Campo.value = vr.substr(0, 2) + '.' + vr.substr(2, tam); if (tam >= 6 && tam < 9) Campo.value = vr.substr(0,2) + '.' + vr.substr(2,3) + '.' + vr.substr(5,tam-5); if (tam >= 9 && tam < 13) Campo.value = vr.substr(0,2) + '.' + vr.substr(2,3) + '.' + vr.substr(5,3) + '/' + vr.substr(8,tam-8); if (tam >= 13 && tam < 15) Campo.value = vr.substr(0,2) + '.' + vr.substr(2,3) + '.' + vr.substr(5,3) + '/' + vr.substr(8,4)+ '-' + vr.substr(12,tam-12); } } </script>
Função Javascript simples para validação de CPFs
Clona / Copia dados digitados em um campo exibe no outro
Nenhum comentário foi encontrado.
Resolver problemas de Internet
Como compartilhar a tela do Ubuntu com uma Smart TV (LG, Samsung, etc.)
Descritores de Arquivos e Swappiness
Como instalar no Linux Jogos da Steam só para Windows
Instalando o Team Viewer no Debian Trixie - problema no Policykit
O Que Fazer Após Instalar Ubuntu 25.04
Redes Wifi não aparecem no Linux Mint cinnamon (4)
Problemas latentes de performance no Ubuntu 25.04 (0)