I'm doing a system in PHP and I would like that when selecting individual or legal entity in the combobox automatically placed the maskara in an imput. I have already researched the net and the examples that have uses 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 the combobox with the value of "1" an AddPlaceHolder error occurs.
Follow 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: