jQuery-Mask-Plugin icon indicating copy to clipboard operation
jQuery-Mask-Plugin copied to clipboard

Two mask in the same field, CPF and cell phone

Open fandrefh opened this issue 8 years ago • 1 comments

What strategy I can use to perform two mask for the same field, CPF and cell phone? I found one for CPF and CNPJ, but to me doesn't work.

PS: Both, CPF and cell phone, it's the same size.

fandrefh avatar Apr 30 '18 13:04 fandrefh

Para Telefone e Celular no mesmo campo: var SPMaskBehavior = function (val) { return val.replace(/\D/g, '').length === 11 ? '(00) 00000-0000' : '(00) 0000-00009'; }, spOptions = { onKeyPress: function(val, e, field, options) { field.mask(SPMaskBehavior.apply({}, arguments), options); } }; $('.mask-phone').mask(SPMaskBehavior, spOptions);

carloshaam avatar Jan 14 '20 18:01 carloshaam