function Trim(valor){ for (i=0;i=0;i--){ if(valor.substr(i,1) != " "){ valor = valor.substr(0,i+1); break; } } return valor; } function ContidoNoDominio(StrDado, Dominio){ var i, j; if (StrDado == "") return false; for (i=0; i= Dominio.length) return false; } return true } function ContemDominio(StrDado, Dominio){ var i, j; if (StrDado != "") { for (i=0; iEMail.length) return false; if (ContemDominio(EMail, " ;,:/$!#%^&*()+[]{}|\\~`'\"")) return false; return true; } function TiraPontos (NumeroFormatado){ var s s = NumeroFormatado.split ("."); return s.join(""); } function TiraTracos (NumeroFormatado){ var s s = NumeroFormatado.split ("-"); return s.join(""); } function IsStrNum(Dado) { return ContidoNoDominio(Dado, "0123456789"); } function CPFvalido(numero) { numero = TiraPontos(TiraTracos(numero)) if (!IsStrNum(numero)) { alert("O campo CPF deve ser númerico."); return (false); } if ((numero.substring(0,11) == "00000000000") || (numero.substring(0,11) == "11111111111") || (numero.substring(0,11) == "22222222222") || (numero.substring(0,11) == "33333333333") || (numero.substring(0,11) == "44444444444") || (numero.substring(0,11) == "55555555555") || (numero.substring(0,11) == "66666666666") || (numero.substring(0,11) == "77777777777") || (numero.substring(0,11) == "88888888888") || (numero.substring(0,11) == "99999999999") || (numero.substring(0,11) == "12345678909") || (numero.substring(0,6) == "000000")) { alert("CPF inválido! Por favor, corrija-o."); return (false); } if (numero.length!=11) { alert("O tamanho correto do CPF é 11 dígitos"); return(false); } if (numero.length==11) { multiplicado = numero.charAt(0) * 1 + numero.charAt(1) * 2 + numero.charAt(2) * 3 + numero.charAt(3) * 4 + numero.charAt(4) * 5 + numero.charAt(5) * 6 + numero.charAt(6) * 7 + numero.charAt(7) * 8 + numero.charAt(8) * 9 ; verificador1 = multiplicado%11 if (verificador1 == 10) verificador1 = 0; multiplicado = numero.charAt(1) * 1 + numero.charAt(2) * 2 + numero.charAt(3) * 3 + numero.charAt(4) * 4 + numero.charAt(5) * 5 + numero.charAt(6) * 6 + numero.charAt(7) * 7 + numero.charAt(8) * 8 + numero.charAt(9) * 9 ; verificador2 = multiplicado%11 if (verificador2 == 10) verificador2 = 0; if ( (verificador1!=numero.charAt(9)) || (verificador2!=numero.charAt(10)) ) { alert("CPF inválido! Por favor, corrija-o."); return (false); } } return (true); } function minuscula(str) { aux = str.value.toLowerCase(); str.value = aux; } function alerta_erro(f,erro,campo) { //alerta erros em formularios if (erro!='') alert(erro) if (campo!='') { obj = eval('f.'+campo); if (obj!=undefined) { class_old = obj.className; obj.className='inputerro'; fct = obj.onblur; obj.onblur = function(){this.className=class_old;retorna_onblur(obj,fct)}; //posY = findPosY(obj); //tamY = (window.outerHeight!=undefined)?window.outerHeight:screen.availHeight; //if (posY>tamY*0.8) // window.scrollTo(0,posY-70); obj.focus(); } else alert('Campo não encontrado: \n'+campo); } return(false); } function retorna_onblur(obj,fct) { if (fct!=undefined) fct(); obj.onblur = fct; } function FormataCPF(Obj) { Dado = PassaDominio(Obj.value, "0123456789"); var l = Dado.length; if((l > 3) && (l <= 6)) Dado = Dado.substr(0, 3) + "." + Dado.substr(3, 3); if((l > 6) && (l <= 9)) Dado = Dado.substr(0, 3) + "." + Dado.substr(3, 3) + "." + Dado.substr(6, 3); if(l > 9) Dado = Dado.substr(0, 3) + "." + Dado.substr(3, 3) + "." + Dado.substr(6, 3) + "-" + Dado.substr(9, 2); Obj.value = Dado; } function PassaDominio(StrDado, Dominio) { var i, j, c; var Result; Result = ""; for (i=0; i