1 function eh_numero(value){ 2 var er = /^[0-9]+$/; 3 return (er.test(value)) ? true : false; 4 } 5 6 var element = document.createElement('div'); 7 function decodeHTMLEntities (str) { 8 if(str && typeof str === 'string') { 9 // strip script/html tags 10 str = str.replace(/<script[^>]*>([\S\s]*?)<\/script>/gmi, ''); 11 str = str.replace(/<\/?\w(?:[^"'>]|"[^"]*"|'[^']*')*>/gmi, ''); 12 element.innerHTML = str; 13 str = element.textContent; 14 element.textContent = ''; 15 } 16 17 return str; 18 } 19 20 function valida_formato(arquivo){ 21 var extensoes, ext, valido; 22 extensoes = new Array('.odt','.pdf','.doc','.xls','.txt'); 23 24 ext = arquivo.substring(arquivo.lastIndexOf(".")).toLowerCase(); 25 valido = false; 26 27 for(var i = 0; i <= arquivo.length; i++){ 28 if(extensoes[i] == ext){ 29 valido = true; 30 break; 31 } 32 } 33 34 if(valido){ 35 return true; 36 } 37 else { 38 return false; 39 } 40 } 41 42 // Máscara para email 43 function valida_email(email){ 44 var str = email; 45 var filtro = /^([\w-]+(?:\.[\w-]+)*)@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$/i; 46 if(filtro.test(str)) { 47 return true; 48 } else { 49 return false; 50 } 51 } 52 53 // Máscara para telefone 54 function mascara_telefone(obj,prox) { 55 switch (obj.value.length) { 56 case 1: 57 obj.value = "(" + obj.value; 58 break; 59 case 3: 60 obj.value = obj.value + ")"; 61 break; 62 case 8: 63 obj.value = obj.value + "-"; 64 break; 65 case 13: 66 prox.focus(); 67 break; 68 } 69 } 70 71 // Por máscara e validar CNPJ 72 function maskCNPJ(cnpj){ 73 if(mascaraInteiro(cnpj)==false){ 74 event.returnValue = false; 75 } 76 return formataCampo(cnpj, '00.000.000/0000-00', event); 77 } 78 79 function mascaraInteiro(){ 80 if (event.keyCode < 48 || event.keyCode > 57){ 81 event.returnValue = false; 82 return false; 83 } 84 return true; 85 } 86 function formataCampo(campo, Mascara, evento) { 87 var boleanoMascara; 88 89 var Digitato = evento.keyCode; 90 exp = /\-|\.|\/|\(|\)| /g 91 campoSoNumeros = campo.value.toString().replace( exp, "" ); 92 93 var posicaoCampo = 0; 94 var NovoValorCampo=""; 95 var TamanhoMascara = campoSoNumeros.length;; 96 97 if (Digitato != 8) { // backspace 98 for(i=0; i<= TamanhoMascara; i++) { 99 boleanoMascara = ((Mascara.charAt(i) == "-") || (Mascara.charAt(i) == ".") 100 || (Mascara.charAt(i) == "/")) 101 boleanoMascara = boleanoMascara || ((Mascara.charAt(i) == "(") 102 || (Mascara.charAt(i) == ")") || (Mascara.charAt(i) == " ")) 103 if (boleanoMascara) { 104 NovoValorCampo += Mascara.charAt(i); 105 TamanhoMascara++; 106 }else { 107 NovoValorCampo += campoSoNumeros.charAt(posicaoCampo); 108 posicaoCampo++; 109 } 110 } 111 campo.value = NovoValorCampo; 112 return true; 113 } 114 else { 115 return true; 116 } 117 } 118 119 function validaCNPJ(ObjCnpj){ 120 var cnpj = ObjCnpj.value; 121 var valida = new Array(6,5,4,3,2,9,8,7,6,5,4,3,2); 122 var dig1= new Number; 123 var dig2= new Number; 124 125 exp = /\.|\-|\//g 126 cnpj = cnpj.toString().replace( exp, "" ); 127 var digito = new Number(eval(cnpj.charAt(12)+cnpj.charAt(13))); 128 129 for(i = 0; i<valida.length; i++){ 130 dig1 += (i>0? (cnpj.charAt(i-1)*valida[i]):0); 131 dig2 += cnpj.charAt(i)*valida[i]; 132 } 133 dig1 = (((dig1%11)<2)? 0:(11-(dig1%11))); 134 dig2 = (((dig2%11)<2)? 0:(11-(dig2%11))); 135 136 if(((dig1*10)+dig2) != digito){ 137 document.getElementById("resp_cnpj").innerHTML='<img src="imagens/img_alert.png" align="absmiddle" alt="" width="17" height="17" /> CNPJ inválido.'; 138 document.getElementById("resp_cnpj").className="alertanegativo"; 139 ObjCnpj.value=""; 140 } 141 else { 142 document.getElementById("resp_cnpj").innerHTML='<img src="imagens/img_visto_ok.png" align="absmiddle" alt="" width="17" height="17" />Ok, CNPJ válido.'; 143 document.getElementById("resp_cnpj").className="alertapositivo"; 144 } 145 146 } 147 148 // Por máscara e validar CPF 149 function maskCPF(CPF) { 150 var evt = window.event; 151 kcode=evt.keyCode; 152 if (kcode == 8) return; 153 if (CPF.value.length == 3) { CPF.value = CPF.value + '.'; } 154 if (CPF.value.length == 7) { CPF.value = CPF.value + '.'; } 155 if (CPF.value.length == 11) { CPF.value = CPF.value + '-'; } 156 } 157 158 function validaCPF(cpf) { 159 erro = new String; 160 161 retiraFormatacao(cpf); 162 /*cpf.value = cpf.value.replace('.', ''); 163 cpf.value = cpf.value.replace('.', ''); 164 cpf.value = cpf.value.replace('-', '');*/ 165 166 if (cpf.value.length == 11){ 167 168 var nonNumbers = /\D/; 169 170 if (nonNumbers.test(cpf.value)) { 171 erro = "A verificacao de CPF suporta apenas números!"; 172 } 173 else{ 174 if (cpf.value == "00000000000" || 175 cpf.value == "11111111111" || 176 cpf.value == "22222222222" || 177 cpf.value == "33333333333" || 178 cpf.value == "44444444444" || 179 cpf.value == "55555555555" || 180 cpf.value == "66666666666" || 181 cpf.value == "77777777777" || 182 cpf.value == "88888888888" || 183 cpf.value == "99999999999") { 184 185 erro = "Número de CPF inválido!" 186 } 187 188 var a = []; 189 var b = new Number; 190 var c = 11; 191 192 for (i=0; i<11; i++){ 193 a[i] = cpf.value.charAt(i); 194 if (i < 9) b += (a[i] * --c); 195 } 196 197 if ((x = b % 11) < 2) { a[9] = 0 } else { a[9] = 11-x } 198 b = 0; 199 c = 11; 200 201 for (y=0; y<10; y++) b += (a[y] * c--); 202 203 if ((x = b % 11) < 2) { a[10] = 0; } else { a[10] = 11-x; } 204 205 if ((cpf.value.charAt(9) != a[9]) || (cpf.value.charAt(10) != a[10])) { 206 erro = "Número de CPF inválido."; 207 } 208 209 if (erro.length > 0) { 210 cpf.focus(); 211 //return false; 212 document.getElementById("resp_cpf").innerHTML='<img src="imagens/img_alert.png" align="absmiddle" alt="" width="17" height="17" /> CPF inválido.'; 213 document.getElementById("resp_cpf").className="alertanegativo"; 214 cpf.value=""; 215 } 216 else{ 217 //return true; 218 document.getElementById("resp_cpf").innerHTML='<img src="imagens/img_visto_ok.png" align="absmiddle" alt="" width="17" height="17" />Ok, CPF válido.'; 219 document.getElementById("resp_cpf").className="alertapositivo"; 220 formataCPF(cpf); 221 } 222 } 223 } 224 else if (cpf.value.length < 11) { 225 //return false; 226 document.getElementById("resp_cpf").innerHTML='<img src="imagens/img_alert.png" align="absmiddle" alt="" width="17" height="17" /> CPF inválido.'; 227 document.getElementById("resp_cpf").className="alertanegativo"; 228 cpf.value=""; 229 230 } 231 232 } 233 234 function formataCPF(CPF){ 235 with (CPF){ 236 value = value.substr(0, 3) + '.' + 237 value.substr(3, 3) + '.' + 238 value.substr(6, 3) + '-' + 239 value.substr(9, 2); 240 } 241 } 242 243 function retiraFormatacao(CPF){ 244 with (CPF){ 245 value = value.replace (".",""); 246 value = value.replace (".",""); 247 value = value.replace ("-",""); 248 value = value.replace ("/",""); 249 } 250 }
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.