Can anyone help me?
I have an input in which it is CPF / CNPJ, how do I make a mask containing two different values for the same field? And how would the code contain an additional telephone field? In other words, masks on the input cpf / cnpj and masks on the phone, I just got from cpf, I can not get the phone together!
<input type="text" name="cpf" id="cpf">
<input type="text" name="tel" id="tel">
$(document).ready(function(){
var SPMaskBehavior = function (val) {
return val.replace(/\D/g, '').length === 11 ? '000.000.000.00' : '00.000.000/0000-01';
},
spOptions = {
onKeyPress: function(val, e, field, options) {
field.mask(SPMaskBehavior.apply({}, arguments), options);
}
};
$('#cpf').mask(SPMaskBehavior, spOptions);
});