1function dateMask(objEvent, objeto) 2{ 3 keypress = getKeyPress(objEvent); 4 5 campo = eval(objeto); 6 caracteres = '01234567890'; 7 separacoes = 2; 8 separacao1 = '/'; 9 separacao2 = '/'; 10 conjunto1 = 2; 11 conjunto2 = 2; 12 conjunto3 = 4; 13 if ((caracteres.search(String.fromCharCode(keypress))!=-1) && campo.value.length < (conjunto1 + conjunto2 + conjunto3 + separacoes)) 14 { 15 if (campo.value.length == conjunto1) 16 campo.value = campo.value + separacao1; 17 18 if (campo.value.length == conjunto1 + conjunto2 + 1) 19 campo.value = campo.value + separacao2; 20 } 21} 22 23function fullTimeMask(objEvent, objeto) { 24 keypress = getKeyPress(objEvent); 25 26 campo = eval(objeto); 27 caracteres = '01234567890'; 28 separacoes = 2; 29 separacao1 = ':'; 30 conjunto1 = 2; 31 conjunto2 = 2; 32 conjunto3 = 2; 33 if ((caracteres.search(String.fromCharCode(keypress))!=-1) && campo.value.length < (conjunto1 + conjunto2 + conjunto3 + separacoes)) { 34 if (campo.value.length == conjunto1 || campo.value.length == (conjunto2 + conjunto2 + 1)) 35 campo.value = campo.value + separacao1; 36 } 37} 38 39function timeMask(objEvent, objeto) 40{ 41 keypress = getKeyPress(objEvent); 42 43 campo = eval(objeto); 44 caracteres = '01234567890'; 45 separacoes = 1; 46 separacao1 = ':'; 47 conjunto1 = 2; 48 conjunto2 = 4; 49 if ((caracteres.search(String.fromCharCode(keypress))!=-1) && campo.value.length < (conjunto1 + conjunto2 + separacoes)) 50 { 51 if (campo.value.length == conjunto1) 52 campo.value = campo.value + separacao1; 53 } 54} 55 56function cepMask(objEvent, objeto) 57{ 58 keypress = getKeyPress(objEvent); 59 60 campo = eval(objeto); 61 caracteres = '01234567890'; 62 separacoes = 1; 63 separacao1 = '-'; 64 conjunto1 = 5; 65 conjunto2 = 8; 66 if ((caracteres.search(String.fromCharCode(keypress))!=-1) && campo.value.length < (conjunto1 + conjunto2 + separacoes)) 67 { 68 if (campo.value.length == conjunto1) 69 campo.value = campo.value + separacao1; 70 } 71} 72 73function phoneMask(objEvent, objeto) 74{ 75 keypress = getKeyPress(objEvent); 76 77 campo = eval(objeto); 78 caracteres = '01234567890'; 79 separacoes = 2; 80 separacao1 = ' '; 81 separacao2 = '-'; 82 conjunto1 = 2; 83 conjunto2 = 4; 84 conjunto3 = 4; 85 if ((caracteres.search(String.fromCharCode(keypress))!=-1) && campo.value.length < (conjunto1 + conjunto2 + conjunto3 + separacoes)) 86 { 87 if (campo.value.length == conjunto1) 88 campo.value = campo.value + separacao1; 89 90 if (campo.value.length == conjunto1 + conjunto2 + 1) 91 campo.value = campo.value + separacao2; 92 } 93} 94 95/*Criado por Lucas e Cassyus 96*função para validação 97*de número, utilizada 98*na TAG NUMBER 99*/ 100function validateNumber(eventoCampo){ 101 if (eventoCampo.ctrlKey) 102 return true; 103 104 if(eventoCampo.shiftKey && eventoCampo.charCode === 38 || eventoCampo.keyCode === 38) 105 return false; 106 107 var tecla = eventoCampo.keyCode || eventoCampo.charCode; 108 var TCL_BKSP = 8; 109 var TCL_TAB = 9; 110 var TCL_ESQ = 37; 111 var TCL_CIMA = 38; 112 var TCL_DIR = 39; 113 var TCL_BXO = 40; 114 var TCL_VIRG = 44; 115 var TCL_MEN = 45; 116 var TCL_DEL = 127; 117 var TCL_ENT = 13; 118 var TCL_ESC = 27; 119 switch (tecla) { 120 case TCL_DEL: 121 return true; 122 case TCL_BKSP: 123 return true; 124 case TCL_TAB: 125 return true; 126 case TCL_ESQ: 127 return true; 128 case TCL_CIMA: 129 return true; 130 case TCL_DIR: 131 return true; 132 case TCL_BXO: 133 return true; 134 case TCL_MEN: 135 return true; 136 case TCL_ENT: 137 return true; 138 default: 139 break; 140 } 141 142 //Não é permitido digitar '.' na entrada de dados 143 if(String.fromCharCode(tecla) == ".") 144 return false; 145 146 //Não pode ter duas virgulas 147 if(String.fromCharCode(tecla) == "," && Event.element(eventoCampo).value.indexOf(",") != -1) 148 return false; 149 150 return /^[0-9.,-]$/.test(String.fromCharCode(tecla)); 151} 152 153 154/** 155 * Utilizar no evento "onkeydown" do campo. 156 * Exemplo: <input type="text" onkeydown="return validateOnlyNumber(event);" /> 157 */ 158function validateOnlyNumber(eventoCampo) { 159 if (eventoCampo.ctrlKey) 160 return true; 161
162 var tecla = eventoCampo.keyCode || eventoCampo.charCode; 163 var TCL_BKSP = 8; 164 var TCL_TAB = 9; 165 var TCL_ESQ = 37; 166 var TCL_CIMA = 38; 167 var TCL_DIR = 39; 168 var TCL_BXO = 40; 169 var TCL_DEL = 46; 170 var TCL_ENT = 13; 171 var TCL_ESC = 27; 172 switch (tecla) { 173 case TCL_DEL: 174 return true; 175 case TCL_BKSP: 176 return true; 177 case TCL_TAB: 178 return true; 179 case TCL_ESQ: 180 return true; 181 case TCL_CIMA: 182 return true; 183 case TCL_DIR: 184 return true; 185 case TCL_BXO: 186 return true; 187 case TCL_DEL: 188 return true; 189 case TCL_ENT: 190 return true; 191 case TCL_ESC: 192 return true; 193 } 194 return ((tecla >= 48 && tecla <= 57) || (tecla >= 96 && tecla <= 105)); 195} 196 197/** 198*Funções abaixo são para formatar números decimais 199*Devem ser utilizadas com o evento onkeydown no campo 200*Lucas 201*19/06/2008 202*/ 203 204function decimalClear(valor, validos) { 205// retira caracteres invalidos da string 206 var result = ""; 207 var aux; 208 for (var i=0; i < valor.length; i++) { 209 aux = validos.indexOf(valor.substring(i, i+1)); 210 if (aux>=0) { 211 result += aux; 212 } 213 } 214 return result; 215} 216 217//Formata número com 2 casas decimais usando o evento onKeyDown 218 219function decimalMask(campo,tammax,teclapres,decimal) { 220 var tecla = teclapres.keyCode; 221 vr = decimalClear(campo.value,"0123456789"); 222 tam = vr.length; 223 dec=decimal 224 225 if (tam < tammax && tecla != 8){ tam = vr.length + 1 ; } 226 227 if (tecla == 8 ) 228 { tam = tam - 1 ; } 229 230 if ( tecla == 8 || tecla >= 48 && tecla <= 57 || tecla >= 96 && tecla <= 105 ) 231 { 232 233 if ( tam <= dec ) 234 { campo.value = vr ; } 235 236 if ( (tam > dec) && (tam <= 5) ){ 237 campo.value = vr.substr( 0, tam - 2 ) + "," + vr.substr( tam - dec, tam ) ; } 238 if ( (tam >= 6) && (tam <= 8) ){ 239 campo.value = vr.substr( 0, tam - 5 ) + "." + vr.substr( tam - 5, 3 ) + "," + vr.substr( tam - dec, tam ) ; 240 } 241 if ( (tam >= 9) && (tam <= 11) ){ 242 campo.value = vr.substr( 0, tam - 8 ) + "." + vr.substr( tam - 8, 3 ) + "." + vr.substr( tam - 5, 3 ) + "," + vr.substr( tam - dec, tam ) ; } 243 if ( (tam >= 12) && (tam <= 14) ){ 244 campo.value = vr.substr( 0, tam - 11 ) + "." + vr.substr( tam - 11, 3 ) + "." + vr.substr( tam - 8, 3 ) + "." + vr.substr( tam - 5, 3 ) + "," + vr.substr( tam - dec, tam ) ; } 245 if ( (tam >= 15) && (tam <= 17) ){ 246 campo.value = vr.substr( 0, tam - 14 ) + "." + vr.substr( tam - 14, 3 ) + "." + vr.substr( tam - 11, 3 ) + "." + vr.substr( tam - 8, 3 ) + "." + vr.substr( tam - 5, 3 ) + "," + vr.substr( tam - 2, tam ) ;} 247 } 248 249} 250//valida o value do elemento passado para ter uma data. 251//caso a data seja invalida, a mensagem de erro padrao do sistema é exibida. 252//caso o campo esteja vazio, na aplica validacao 253validateDate = function(o){ 254 clearMessage(); 255 if(o.value.empty() || o.value.blank()) { 256 return; 257 } 258 if( !isDate(o.value) ) { 259 showErrorMessage("Data inválida: "+o.value); 260 o.value=""; 261 } 262} 263//verifica se a data passada é valida. 264isDate = function( value ){ 265var v = maskDateValue(value); 266 var arrData = v.split("/"); 267 if(arrData.length == 3) { 268 if(arrData[1] == undefined || arrData[1] == "") { 269 return false; 270 } 271 272 if(arrData[2] == undefined || arrData[2] == "") { 273 return false; 274 } 275 276 var mes = parseInt(eval(arrData[1])); 277 var ano = parseInt(eval(arrData[2])); 278 var dia = parseInt(eval(arrData[0])); 279 280 /** 281 * Usava array - da erro para o Firefox acima da versão 20. 282 */ 283// var arrDiasMes = daysArray(); 284// if(arrDiasMes[mes] == undefined) { 285// return false; 286// } 287// if(mes == 2 && ano % 4 != 0) { 288// arrDiasMes[mes] = 28; 289// } 290// if((''+ano).length != 4){ 291// return false; 292// } 293// if(dia > arrDiasMes[mes]) { 294// return false; 295// } 296
297 var qtDias = 31; 298 if (mes == 1 || mes == 3 || mes == 5 || mes == 7 || mes == 8 || mes == 10 || mes == 10) { 299 qtDias = 31; 300 } 301 if (mes == 4 || mes == 6 || mes == 9 || mes == 11) { 302 qtDias = 30; 303 } 304 if (mes == 2) { 305 qtDias = 29; 306 } 307 308 if(qtDias == undefined) { 309 return false; 310 } 311 if(mes == 2 && ano % 4 != 0) { 312 qtDias = 28; 313 } 314 if((''+ano).length != 4){ 315 return false; 316 } 317 if(dia > qtDias) { 318 return false; 319 } 320 if(dia == 0){ 321 return false; 322 } 323 return true; 324 } 325 return false; 326} 327 328isValidYear = function(o){ 329 var v = maskDateValue(o.value); 330 var arrData = v.split("/"); 331 332 if(arrData.length == 3) { 333 334 var ano = parseInt(eval(arrData[2])); 335 336 if(ano > 2050 ) { 337 showMessageYear(o); 338 } 339 if(ano < 1900 ) { 340 showMessageYear(o); 341 } 342 } 343 return true; 344} 345 346function showMessageYear(o){ 347 clearMessage(); 348 showErrorMessage("Data inválido: "+o.value); 349 o.value=""; 350} 351 352//cria array com o numero maximo de dias por mes 353daysArray = function (){ 354 var n = 12; 355 for (var i = 1; i <= n; i++) { 356 this[i] = 31; 357 if (i==4 || i==6 || i==9 || i==11) { 358 this[i] = 30; 359 } 360 if (i==2) { 361 this[i] = 29; 362 } 363 } 364 return this 365} 366 367//aplica mascara dd/MM/yyyy na string passada. 368maskDateValue = function ( v ) 369{ 370 v = v.replace(/\D/g,""); 371 v = v.replace(/(\d{2})(\d)/,"$1/$2"); 372 v = v.replace(/(\d{2})(\d)/,"$1/$2"); 373 return v; 374} 375 376function cnaeMask(objEvent, objeto) 377{ 378 keypress = getKeyPress(objEvent); 379 380 campo = eval(objeto); 381 caracteres = '01234567890'; 382 separacoes = 2; 383 separacao1 = '-'; 384 separacao2 = '/'; 385 conjunto1 = 4; 386 conjunto2 = 1; 387 conjunto3 = 2; 388 if ((caracteres.search(String.fromCharCode(keypress))!=-1) && campo.value.length < (conjunto1 + conjunto2 + conjunto3 + separacoes)) 389 { 390 if (campo.value.length == conjunto1) 391 campo.value = campo.value + separacao1; 392 393 if (campo.value.length == conjunto1 + conjunto2 + 1) 394 campo.value = campo.value + separacao2; 395 } 396} 397 398function priceFormat(obj) { 399 new NumberFormat(obj.name, {prefix: '', thousandsSeparator: '.', centsSeparator: ',', allowNegative: false}); 400}
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.