function verifica_data (inputBox) { dia = (inputBox.value.substring(0,2)); mes = (inputBox.value.substring(3,5)); ano = (inputBox.value.substring(6,10)); situacao = ""; // verifica o dia valido para cada mes if ((dia < 01)||(dia < 01 || dia > 30) && ( mes == '04' || mes == '06' || mes == '09' || mes == '11' ) || dia > 31) { situacao = "falsa"; } // verifica se o mes e valido if (mes < 01 || mes > 12 ) { situacao = "falsa"; } // verifica se e ano bissexto if (mes == 2 && ( dia < 01 || dia > 29 || ( dia > 28 && (parseInt(ano / 4) != ano / 4)))) { situacao = "falsa"; } if (inputBox.value == "") { situacao = "falsa"; } if (situacao == "falsa") { //alert("Data inválida!"); return false; } return true; } function validaCPF(inputBox) { cpf = inputBox.value; erro = new String; if (cpf.length < 11) erro += "Sao necessarios 11 digitos para verificacao do CPF! \n\n"; var nonNumbers = /\D/; if (nonNumbers.test(cpf)) erro += "A verificacao de CPF suporta apenas numeros! \n\n"; if (cpf == "00000000000" || cpf == "11111111111" || cpf == "22222222222" || cpf == "33333333333" || cpf == "44444444444" || cpf == "55555555555" || cpf == "66666666666" || cpf == "77777777777" || cpf == "88888888888" || cpf == "99999999999"){ erro += "Numero de CPF invalido!"; } var a = []; var b = new Number; var c = 11; for (i=0; i<11; i++){ a[i] = cpf.charAt(i); if (i < 9) b += (a[i] * --c); } if ((x = b % 11) < 2) { a[9] = 0 } else { a[9] = 11-x } b = 0; c = 11; for (y=0; y<10; y++) b += (a[y] * c--); if ((x = b % 11) < 2) { a[10] = 0; } else { a[10] = 11-x; } if ((cpf.charAt(9) != a[9]) || (cpf.charAt(10) != a[10])){ erro +="Digito verificador do CPF com problema!"; } if (erro.length > 0){ return false; } return true; } function estah_vazio(inputBox) { v_campo = inputBox.value; v_qtde = v_campo.length; j = 0; while (j < v_qtde) { if ((v_campo.charAt(j) != "") && (v_campo.charAt(j) != " ")) return false; j = j + 1; } return true; } function eh_numerico(inputBox) { v_campo = inputBox.value; v_qtde = v_campo.length; j = 0; while (j < v_qtde) { if ((v_campo.charAt(j) < "0") || (v_campo.charAt(j) > "9")) return false; j = j + 1; } return true; } function tem_branco(inputBox) { v_campo = inputBox.value; if(v_campo.indexOf(" ") == -1) return false; return true; } function testaEmail(txtInput) { email = txtInput.value; if (email == "") { alert("Informe um e-mail correto."); txtInput.focus(); return false; } else { if ((email.indexOf('@') == email.lastIndexOf('@')) && // só tem um @ (email.indexOf('@') > 0) && // existe @ e não é prim (email.charAt(email.length-1) != '@') && // @ não é o último (email.indexOf(' ') == -1) && // não existe espaços (email.lastIndexOf('.') > email.indexOf('@')) && // existe . após @ (email.charAt(email.indexOf('@') + 1) != '.') && // sem . logo após @ (email.charAt(email.indexOf('@') - 1) != '.') && // sem . logo antes @ (email.indexOf('.') > 0) && // existe . e não é prim (email.charAt(email.length-1) != '.')) { // . não é o último // verifica se não há pontos seguidos sub = email.substring(email.indexOf('.')+1, email.length); while (sub.indexOf('.') != -1) { if (sub.charAt(0) == '.') { alert("Formato de e-mail incorreto!"); txtInput.focus(); return false; } else { sub = sub.substring(sub.indexOf('.')+1, sub.length); } } return true; } else { txtInput.focus(); return false; } } } function validaCEP(cep) { if(cep.length == 8) { return true; }else{ return false; } }