Created
May 6, 2014 20:04
-
-
Save brunopulis/9d6e34c29c600b8f8111 to your computer and use it in GitHub Desktop.
MaskInput
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
maskTelefone: function() { | |
$( "#telefone" ).mask( "(99) 9999-9999?9" ).live('focusout', function (event) { | |
var target, phone, element; | |
target = (event.currentTarget) ? event.currentTarget : event.srcElement; | |
phone = target.value.replace(/\D/g, ''); | |
element = $(target); | |
element.unmask(); | |
if(phone.length > 10) | |
element.mask("(99) 99999-999?9"); | |
else | |
element.mask("(99) 9999-9999?9"); | |
}); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment