igorescobar / jQuery-Mask-Plugin

A jQuery Plugin to make masks on form fields and HTML elements.
http://igorescobar.github.io/jQuery-Mask-Plugin/
Other
4.77k stars 1.42k forks source link

Mask Phone SP + clearIfNotMatch #646

Closed ftbraian closed 6 years ago

ftbraian commented 6 years ago

Igor como poderia colocar o 'clearIfNotMatch = true' no exemplo da mask para telefone com novo digito:

var maskBehavior = function (val) { return val.replace(/\D/g, '').length === 11 ? '(00) 00000-0000' : '(00) 0000-00009'; }, options = {onKeyPress: function(val, e, field, options) { field.mask(maskBehavior.apply({}, arguments), options); } };

$('.phone').mask(maskBehavior, options);

ou teria como colocar o clearIfNotMatch true para todos as mask ?

abs

igorescobar commented 6 years ago

Olá @ftbraian !

Infelizmente o clearIfNotMatch não é uma opção global e sim de cada input.