Closed KelvinRonaldo closed 3 years ago
I'm trying to make an On-the-fly mask change creating an CPF/CNPJ mask:
JavaScript
$(document).ready(function(){ var cpfCnpjMask = { onKeyPress: function(cpfCnpj, e, field, options) { var masks = ['000.000.000-00', '00.000.000/0000-00']; var mask = (cpfCnpj.length > 11) ? masks[1] : masks[0]; $('.cpf-cnpj-mask').mask(mask, cpf-cnpj-mask); } }; $('.cpf-cnpj-mask').mask('000.000.000-00', cpfCnpjMask); }
HTML
<label>Documento</label> <input type="text" class="form-control cpf-cnpj-mask" name="document">
I'm using laravel, so this html code is in an .blade.php file. The other masks without callback functions work normally, but with callback doesn't have any effect.
I'm trying to make an On-the-fly mask change creating an CPF/CNPJ mask:
JavaScript
HTML
I'm using laravel, so this html code is in an .blade.php file. The other masks without callback functions work normally, but with callback doesn't have any effect.