Last active
August 29, 2015 14:07
-
-
Save KaduNovoK/33f2c09475ca07d49a93 to your computer and use it in GitHub Desktop.
[JQuery] Phone and Cellphone Mask
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 = $("#fos_user_registration_form_phone"); | |
var maskOptions = {onKeyPress: function(phone) { | |
var masks = ['(00) 0000-0000', '(00) 00000-0000']; | |
mask = phone.match(/^\([0-9]{2}\) 9/g) | |
? masks[1] | |
: masks[0]; | |
$phone.mask(mask, this); | |
}}; | |
$phone.mask('(00) 0000-0000', maskOptions); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment