Skip to content

Instantly share code, notes, and snippets.

@rodolfofadino
Created October 14, 2012 14:54
Show Gist options
  • Save rodolfofadino/3888829 to your computer and use it in GitHub Desktop.
Save rodolfofadino/3888829 to your computer and use it in GitHub Desktop.
9-digitos
$('#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