Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- {if $filename eq 'register' or $filename eq 'cart' or $filename eq 'clientarea'}
- <script src='https://www.google.com/recaptcha/api.js'></script>
- <script type="text/javascript" src="{$WEB_ROOT}/templates/{$template}/js/valida_cpf_cnpj.js"></script>
- <script type="text/javascript" src="{$WEB_ROOT}/templates/{$template}/js/telefone.js"></script>
- {literal}
- <script>
- $(function(){
- // Aciona a validação e formatação ao sair do input
- $('#customfield58').blur(function(){ // aqui você deve colocar o ID gerado pelo campo personalizado no WHMCS
- var cpf_cnpj = $(this).val();
- // Testa a validação e formata se estiver OK
- if ( formata_cpf_cnpj( cpf_cnpj ) ) {
- $(this).val( formata_cpf_cnpj( cpf_cnpj ) );
- $('p.invalido').remove(); // remove o aviso de inválido se existir
- } else {
- $(this).val("");
- if ($('p.invalido').length > 0) {
- } else {
- $(this).after( "<p class='invalido' style='color:red;'>CPF ou CNPJ inválido.</p>" ); // adiciona o aviso de inválido se não já existir logo abaixo do campo
- }
- }
- });
- });
- </script>
- <script> //permite apenas números no campo CPF ou CNPJ
- $(document).ready(function(){
- function onlyNumber(fields){
- $(fields).unbind('keyup').bind('keyup',function(e){
- var thisVal = $(this).val();
- var tempVal = "";
- for(var i = 0; i<thisVal.length; i++){
- if(RegExp(/^[0-9]$/).test(thisVal.charAt(i))){
- tempVal += thisVal.charAt(i);
- if(e.keyCode == 8){
- tempVal = thisVal.substr(0,i);
- }
- }
- }
- $(this).val(tempVal);
- });
- }
- onlyNumber($('#customfield58')); //aqui adicione o ID gerado pelo campo do WHMCS
- });
- </script>
- {/literal}
- {/if}
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement