Created
March 5, 2018 19:26
-
-
Save olivx/7491c939e708ef0438382bcd783799b0 to your computer and use it in GitHub Desktop.
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
var phone_mask = function (val) { | |
return val.replace(/\D/g, '').length === 11 ? '(00) 00000-0000' : '(00) 0000-00009'; | |
}, | |
phone_option = { | |
onKeyPress: function (val, e, field, options) { | |
field.mask(phone_mask.apply({}, arguments), options); | |
} | |
}; | |
$('#id_phone').mask(phone_mask, phone_option); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment