carlos.verza
7/1/2019 - 8:01 PM

jQuery Masks

jQuery(document).ready(function($) {

	/* Input Masks - Begin */
		var phoneMaskBehavior = function (val) {
		  return val.replace(/\D/g, '').length === 11 ? '(00) 00000-0000' : '(00) 0000-00009';
		},
		phoneOptions = {
		  onKeyPress: function(val, e, field, options) {
		      field.mask(phoneMaskBehavior.apply({}, arguments), options);
		    }
		};
	
		$('.input-phone').mask(phoneMaskBehavior, phoneOptions);
		$('.input-money').mask("#.##0,00", {reverse: true});
		$('.input-cep').mask("00000-000");
		$('.input-cpf').mask("000.000.000-00");
	/* Input Masks - End */
	
});