Created
May 5, 2016 16:46
-
-
Save Godoy/0291b55ad47161c68a222232e9981e9c to your computer and use it in GitHub Desktop.
jquery mask phone telefone 9 digitos
This file contains 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
// https://github.com/igorescobar/jQuery-Mask-Plugin/tree/master/dist | |
$(function () { | |
$('.phone').mask(PhoneMaskBehavior, spOptions); | |
}); | |
var PhoneMaskBehavior = function (val) { | |
return val.replace(/\D/g, '').length === 11 ? '(00) 00000-0000' : '(00) 0000-00009'; | |
}, | |
spOptions = { | |
onKeyPress: function (val, e, field, options) { | |
field.mask(PhoneMaskBehavior.apply({}, arguments), options); | |
} | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment