Created
September 25, 2012 18:25
-
-
Save deivisonarthur/3783565 to your computer and use it in GitHub Desktop.
teste se é taxvat ou cpfcnpj e alterna os names
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
| /*===================================================== Click ===========================================================*/ | |
| /*Roda o clique para selecionar o tipo pessoa*/ | |
| $j('input[name*="tipopessoa"]').click( function(){ | |
| var existe; | |
| /*Pega do click tipo pessoa*/ | |
| queme = this.value; | |
| /*Verifica se existe o Taxvat*/ | |
| existe = $j('input[name*="taxvat"]').length; | |
| if(queme == 'Fisica'){ | |
| /*fisica*/ | |
| /*Se existe o Taxvat alterna entre eles mudando o name conforme selecionado o tipo pessoa*/ | |
| if( existe != ''){ | |
| /*CADASTRO*/ | |
| $j('input[name="taxvat-old"]').attr('name', 'taxvat'); | |
| $j('input[name="taxvat"]:eq(1)').attr('name', 'taxvat-old'); | |
| /*CADASTRO*/ | |
| $j('.inputcnpj').attr('name', 'taxvat-old'); | |
| $j('.inputcpf').attr('name', 'taxvat'); | |
| /*BILLING*/ | |
| $j('input[name="billing[taxvat-old]"]').attr('name', 'billing[taxvat]'); | |
| $j('input[name="billing[taxvat]"]:eq(1)').attr('name', 'billing[taxvat-old]'); | |
| /*BILLING*/ | |
| $j('.Binputcnpj').attr('name', "billing[taxvat-old]"); /*CNPJ NULL*/ | |
| $j('.Binputcpf').attr('name', "billing[taxvat]"); /*CPF OK*/ | |
| /*LIMPA CAMPOS*/ | |
| $j('input[name="taxvat"]').val(''); | |
| $j('input[name="billing[taxvat]"]').val(''); | |
| /*ADD CLASS TAXVAT*/ | |
| //$j('input[name*="taxvat"]').attr('class', 'validar_cpfcnpj input-text'); | |
| }else{ | |
| /*CADASTRO*/ | |
| $j('.inputcnpj').attr('name', 'NULL'); | |
| $j('.inputcpf').attr('name', 'cpfcnpj'); | |
| /*BILLING*/ | |
| $j('.Binputcnpj').attr('name', "NULL"); /*CNPJ NULL*/ | |
| $j('.Binputcpf').attr('name', "billing[cpfcnpj]"); /*CPF OK*/ | |
| //$j('.Binputcpf').attr('name', 'oioioi'); | |
| /*LIMPA CAMPOS*/ | |
| $j('input[name="cpfcnpj"]').val(''); | |
| $j('input[name="billing[cpfcnpj]"]').val(''); | |
| } | |
| /*Exibe ou oculta os boxs*/ | |
| $j('.boxpj').hide(); | |
| $j('.boxpf').show(); | |
| /*Exibe ou oculta o entregar em outro endereço conforme a selecao do tipo pessoa*/ | |
| $j('li.options').find("label:contains('Entregar')").css('visibility', 'visible'); | |
| $j('input[name*="[same_as_billing]"]').css('visibility', 'visible'); | |
| }else if(queme == 'Juridica'){ | |
| /*juricica*/ | |
| /*Se existe o Taxvat alterna entre eles mudando o name conforme selecionado o tipo pessoa*/ | |
| if( existe != ''){ | |
| /*CADASTRO*/ | |
| $j('input[name="taxvat-old"]').attr('name', 'taxvat'); | |
| $j('input[name="taxvat"]:eq(0)').attr('name', 'taxvat-old'); | |
| $j('.inputcnpj').attr('name', 'taxvat'); | |
| $j('.inputcpf').attr('name', 'taxvat-old'); | |
| /*BILLING*/ | |
| $j('input[name="billing[taxvat-old]"]').attr('name', 'billing[taxvat]'); | |
| $j('input[name="billing[taxvat]"]:eq(0)').attr('name', 'billing[taxvat-old]'); | |
| /*BILLING*/ | |
| $j('.Binputcnpj').attr('name', "billing[taxvat]"); /*CNPJ NULL*/ | |
| $j('.Binputcpf').attr('name', "billing[taxvat-old]"); /*CPF OK*/ | |
| /*LIMPA CAMPOS*/ | |
| $j('input[name="taxvat"]').val(''); | |
| $j('input[name="billing[taxvat]"]').val(''); | |
| /*ADD CLASS TAXVAT*/ | |
| //$j('input[name*="taxvat"]').attr('class', 'validar_cpfcnpj input-text'); | |
| }else{ | |
| /*CADASTRO*/ | |
| $j('.inputcnpj').attr('name', 'cpfcnpj'); | |
| $j('.inputcpf').attr('name', 'NULL'); | |
| /*BILLING*/ | |
| $j('.Binputcnpj').attr('name', 'billing[cpfcnpj]'); /*CNPJ OK*/ | |
| $j('.Binputcpf').attr('name', 'NULL'); /*CPF NULL*/ | |
| /*LIMPA CAMPOS*/ | |
| $j('input[name="cpfcnpj"]').val(''); | |
| $j('input[name="billing[cpfcnpj]"]').val(''); | |
| } | |
| /*Exibe ou oculta os boxs*/ | |
| $j('.boxpj').show(); | |
| $j('.boxpf').hide(); | |
| /*Exibe ou oculta o entregar em outro endereço conforme a selecao do tipo pessoa*/ | |
| $j('li.options').find("label:contains('Entregar')").css('visibility', 'hidden'); | |
| $j('input[name*="[same_as_billing]"]').css('visibility', 'hidden'); | |
| } | |
| }); | |
| /*===================================================== End Click ===========================================================*/ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment