Skip to content

Instantly share code, notes, and snippets.

@ycaroafonso
Created June 20, 2022 23:54
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ycaroafonso/2c08f4893deff570dbad4792e4641796 to your computer and use it in GitHub Desktop.
Save ycaroafonso/2c08f4893deff570dbad4792e4641796 to your computer and use it in GitHub Desktop.
jQuery(document).ready(function () {
jQuery(".mascaracpf").mask("999.999.999-99");
jQuery(".mascaracnpj").mask("99.999.999/9999-99");
jQuery('.mascaratelefonefixo').mask("(99) 9999-9999");
jQuery(".mascaracep").mask("99.999-999");
jQuery(".mascaradecimalavulso").maskMoney({
allowNegative: true, thousands: "", decimal: ",", affixesStay: false, allowZero: true
});
//$(".mascarasonumeros").attr("onkeypress", "return customNumeric(event, '');");
jQuery(".mascarasonumeros").keypress(function (e) {
//console.log(e.preventDefault());
if (!customNumeric(e, '')) {
e.stopPropagation();
return false;
}
});
$(".mascarahoraminuto").attr("type", "text").mask("99:99");
$(".mascaratimecompleto").attr("type", "text").mask("99:99:99");
$(".mascarasodata").attr("type", "text").mask("99/99/9999");
$(".mascaradata").attr("type", "text").mask("99/99/9999").datepicker({
language: "pt-BR",
autoclose: true,
todayHighlight: true,
format: "dd/mm/yyyy",
clearBtn: true,
});
$(".mascaradatahora").attr("type", "text").mask("99/99/9999 99:99").datepicker({
language: "pt-BR",
autoclose: true,
todayHighlight: true,
format: "dd/mm/yyyy hh:MM",
clearBtn: true,
});
$(".mascaracelular").focusout(function () { //Função para implementar o nono digito de telefones
var
element = jQuery(this).unmask(),
phone = element.val().replace(/\D/g, '');
element.mask(phone.length > 10 ? "(99) 99999-999?9" : "(99) 9999-9999?9");
}).trigger('focusout');
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment