-
-
Save fayqLs/7c3dc9b5f17698acb2b47472ce3e86f2 to your computer and use it in GitHub Desktop.
MUDA A MÁSCARA DO CAMPO CPF/CNPJ AO SELECIONAR O TIPO DE PESSOA DA COMBO
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// DEFININDO A AÇÃO DA COMBOX TIPO PESSOA AO MUDAR DE OPÇÃO | |
$tipo_pessoa->setChangeAction(new TAction([$this,'onTipoPessoa'])); | |
// cpf_cnpj É O NOME DO CAMPO CPF / CNPJ | |
// FUNÇÃO DA COMBO TIPO PESSOA | |
public static function onTipoPessoa($param = null) | |
{ | |
try | |
{ | |
if( $param['tipo_pessoa'] == 'FÍSICA') | |
{ | |
TScript::create("$('label:contains(\"CNPJ\")').html('CPF')"); // MUDA O TEXTO DO LABEL CPF PARA CNPJ | |
TScript::create( " $('input[name=cnpjcpf]').off(); | |
$('input[name=cnpjcpf]').val(''); | |
$('input[name=cnpjcpf]').keypress(function() { tentry_mask(this, event, '999.999.999-99') }); " ); | |
} else { | |
TScript::create("$('label:contains(\"CPF\")').html('CNPJ')"); // MUDA O TEXTO DO LABEL CNPJ PARA CPF | |
TScript::create( " $('input[name=cnpjcpf]').off(); | |
$('input[name=cnpjcpf]').val(''); | |
$('input[name=cnpjcpf]').keypress(function() { tentry_mask(this, event, '99.999.999/9999-99') }); " ); | |
} | |
} | |
catch (Exception $e) | |
{ | |
new TMessage('error', $e->getMessage()); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment