Created
March 2, 2018 19:50
-
-
Save cagartner/e8c0aff3d3dc7fc6e783907806c57da6 to your computer and use it in GitHub Desktop.
Igor Escobar Jquery Input Mask 11 digitos telefones
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment