1/** 2 * Aplica máscaras aos campos que possuem as classes correspondentes 3 */ 4function applyMasks(){ 5 $(".cpfMask").mask("999.999.999-99"); 6 applyNumberMasks(); 7 $(".cepMask").mask("99999-999"); 8} 9 10/** 11 * Aplica máscara para números em todos os campos que possuírem a classe numberMask<br /> 12 * Para isso podem ser utilizados os atributos data-minLength(tamanho mínimo do valor) e data-maxLength(tamanho máximo)<br /> 13 * Caso o valor dos dois atributos não for informado ou se o campo não possuí-los será aplicada uma máscara 14 * para número sem limite de tamanho<br /> 15 * Se somente minLength for informado o tamanho máximo e mínimo do campo será esse<br /> 16 * Se apenas maxLength for informado o valor do campo será opcional mas possuirá o valor máximo 17 */ 18function applyNumberMasks() { 19 var mask = ""; 20 var minLength = 0; 21 var maxLength = 0; 22 var optional = 0; 23 24 $(".numberMask").each(function(){ 25 if($(this).data("minlength")) 26 minLength = $(this).data("minlength"); 27 28 if($(this).data("maxlength")) 29 maxLength = $(this).data("maxlength"); 30 31 if(maxLength == 0 && minLength == 0){ 32 $(this).keydown(function (e) { 33 if ($.inArray(e.keyCode, [46, 8, 9, 27, 13, 110, 190]) !== -1 || (e.keyCode == 65 && e.ctrlKey === true) 34 || (e.keyCode >= 35 && e.keyCode <= 39)) { 35 return; 36 } 37 38 if ((e.shiftKey || (e.keyCode < 48 || e.keyCode > 57)) && (e.keyCode < 96 || e.keyCode > 105)) { 39 e.preventDefault(); 40 } 41 }); 42 43 return true; 44 } 45 46 optional = maxLength - minLength; 47 48 for(var i = 0; i < minLength; i++){ 49 mask += "9"; 50 } 51 52 if(maxLength > 0 && maxLength > minLength) { 53 mask += "?"; 54 55 for(var i = 0; i < optional; i++){ 56 mask += "9"; 57 } 58 } 59 60 $(this).mask(mask, {placeholder: ""}); 61 maxLength = 0; 62 minLength = 0; 63 }); 64} 65
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.