Skip to content

Instantly share code, notes, and snippets.

@chrdesigner
Last active September 14, 2017 21:12
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save chrdesigner/2ba891548db68bbd14c0 to your computer and use it in GitHub Desktop.
Save chrdesigner/2ba891548db68bbd14c0 to your computer and use it in GitHub Desktop.
Máscara em jQuery para o oite e nove dígitos
// <![CDATA[
jQuery(function($) {
$.mask.definitions['~']='[+-]';
//Inicio Mascara Telefone
$('input[type=tel]').focusout(function(){
var phone, element;
element = $(this);
element.unmask();
phone = element.val().replace(/\D/g, '');
if(phone.length > 10) {
element.mask("(99) 99999-999?9");
} else {
element.mask("(99) 9999-9999?9");
}
}).trigger('focusout');
//Fim Mascara Telefone
$("#cpf").mask("999.999.999-99");
$("#rg").mask("99.999.999-*");
});
// ]]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment