0
I am making a system in PHP and I would like when selecting natural or legal person in the combobox to automatically put the maskara in an imput. I have already searched on the net and the examples you have use JQUERY-1.3.2.js, but my project is in JQUERY-2.0.3.min. js, because my template uses.
My problem occurs when I select Individual in combobox with the value of "1" an Addplaceholder error occurs.
follows the code I copied from an example:
<script src="js/jquery/jquery-2.0.3.min.js"></script>
<script>
function aplicaMascara(opcao) {
if (opcao == "1")
document.getElementById("cli_cnpcnpj").setAttribute("onclick","mascaraCPF()");
if (opcao == "2")
document.getElementById("cli_cnpcnpj").setAttribute("onclick","mascaraCNPJ()");
}
function mascaraCPF() {
$(document).ready(function(){
$(function(){
$.mask.addPlaceholder("~","[+-]");
$("#cli_cnpcnpj").mask("999.999.999-99");
});
});
}
function mascaraCNPJ() {
$(document).ready(function(){
$(function(){
$.mask.addPlaceholder("~","[+-]");
$("#cli_cnpcnpj").mask("99.999.999/9999-99");
});
});
}
<div class="col-md-2">
<label class="control-label" for="inputSuccess1">tp. Pessoa</label>
<select data-toggle="tooltip" data-placement="bottom" title="selecione o tipo de pessoa" class="form-control input-sm" id="cli_tppessoa" name="cli_tppessoa" onchange="aplicaMascara(this.value)" >
<option value="TT">[ --selecione o tp de pessoa-- ]</option> <option value="1">Pessoa Física</option>
<option value="2">Pessoa Jurídica</option>
</select>
</div>
But when I look at the developer tool in Chrome the following error appears: