It works while typing, but when I request the table it only comes with the CPF format, if I click on the field and press a key the mask is corrected to CNPJ the CPF mask is working fine only CNPJ does not work
<code>var options = {
onKeyPress: function(cpf, ev, el, op) {
var masks = ['000.000.000-000', '00.000.000/0000-00'];
$('[data-cpfcnpj]').mask((cpf.length > 14) ? masks[1] : masks[0], op);
}
}
$('[data-cpfcnpj]').length > 11 ?
$('[data-cpfcnpj]').mask('00.000.000/0000-00', options) :
$('[data-cpfcnpj]').mask('000.000.000-00#', options);
</code>
<code>var options = {
onKeyPress: function(cpf, ev, el, op) {
var masks = ['000.000.000-000', '00.000.000/0000-00'];
$('[data-cpfcnpj]').mask((cpf.length > 14) ? masks[1] : masks[0], op);
}
}
$('[data-cpfcnpj]').length > 11 ?
$('[data-cpfcnpj]').mask('00.000.000/0000-00', options) :
$('[data-cpfcnpj]').mask('000.000.000-00#', options);
</code>
var options = {
onKeyPress: function(cpf, ev, el, op) {
var masks = ['000.000.000-000', '00.000.000/0000-00'];
$('[data-cpfcnpj]').mask((cpf.length > 14) ? masks[1] : masks[0], op);
}
}
$('[data-cpfcnpj]').length > 11 ?
$('[data-cpfcnpj]').mask('00.000.000/0000-00', options) :
$('[data-cpfcnpj]').mask('000.000.000-00#', options);
New contributor
Jeferson Dev is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
1