Skip to content

Instantly share code, notes, and snippets.

@brunopulis
Created May 6, 2014 20:04
Show Gist options
  • Save brunopulis/9d6e34c29c600b8f8111 to your computer and use it in GitHub Desktop.
Save brunopulis/9d6e34c29c600b8f8111 to your computer and use it in GitHub Desktop.
MaskInput
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