// JavaScript Document function textFormat(formField) { var txt = ""; var carc = ""; var words = formField.value.split(" "); var spcase = new Array("do", "em", "e", "no", "na", "com", "de", "da", "em", "se", "um", "uma", "uns", "se", "o", "a", "lhe", "IBICT", "TSE", "TRE", "SUS", "HRAN", "cnpjq", "meu", "seu", "Sr.", "UnB", "SQN", "SCN", "CDT/UnB", "Cecae/USP"); spcase: for(i=0; i < words.length; i++) { for(k=0; k0 && tam < 8) { mensagem = " Erro de digitação:\n"; mensagem+= " ===============\n\n"; mensagem+= " O Cep: " + e.value + " não existe!!\n\n\n"; mensagem+= " Use o seguinte formato: ddddd-ddd\n\n"; mensagem+= " Exemplo: 70800-200\n"; alert(mensagem); e.focus(); } //Avancar(e); return dv; } function FormataCep(e) { var s = ""; s = FiltraCampo(e.value); tam = s.length; r = s.substring(0,5) + "-" + s.substring(5,8); if ( tam < 6 ) s = r.substring(0,tam); else s = r.substring(0,tam+1); e.value = s; return s; } /*function formataData(campo) { var textoOriginal = campo.value; var textoFormatado = ""; // Limpa qualquer caractere não numerico textoOriginal = forceNumbers(textoOriginal); var tamanho = textoOriginal.length; for (i=0; i= 0) { result += letra; } } return result; } function reverseString(string) { var tamanho = string.length; var result = ""; for (i=0; i255) { alert("Email inválido") txtField.focus(); return false } } return true } var domainArray=domain.match(domainPat) if (domainArray==null) { alert("Email inválido") txtField.focus(); return false } var atomPat=new RegExp(atom,"g") var domArr=domain.match(atomPat) var len=domArr.length if (domArr[domArr.length-1].length<2 || domArr[domArr.length-1].length>3) { alert("Email inválido") txtField.focus(); return false } if (len<2) { var errStr="Email inválido" alert(errStr) txtField.focus(); return false } return true; } function validatePwd() { var invalid = " "; // Invalid character is a space var minLength = 6; // Minimum length var pw1 = document.myForm.password.value; var pw2 = document.myForm.password2.value; // check for a value in both fields. if (pw1 == '' || pw2 == '') { alert('Please enter your password twice.'); return false; } // check for minimum length if (document.myForm.password.value.length < minLength) { alert('Your password must be at least ' + minLength + ' characters long. Try again.'); return false; } // check for spaces if (document.myForm.password.value.indexOf(invalid) > -1) { alert("Sorry, spaces are not allowed."); return false; } else { if (pw1 != pw2) { alert ("You did not enter the same new password twice. Please re-enter your password."); return false; } else { alert('Nice job.'); return true; } } } ///// Checagem de Data 24/02/2004 function DataOk(e) { var strDia=""; var strMes=""; var strAno=""; var Dia=0; var Mes=0; var Ano=0; var Texto=""; //VALOR A SER TESTADO var Msg=""; // MENSAGEM A SER EXIBIDA NA TELA SE HOUVER ERRO var Erro = false; Texto = FormataData(e); // COLOCAR AS BARRAS if (Texto!="") { //EXISTE VALOR // DATA ESTÁ DIGITADA INCOMPLETA if ( Texto.length < 10 && Texto.length != 8 ) { e.value = ''; return true; } strDia = Texto.substring(0,2); strMes = Texto.substring(3,5); strAno = Texto.substring(6); Dia=parseInt(strDia,10); Mes=parseInt(strMes,10); Ano=parseInt(strAno,10); // colocar o ano com 4 digitos se o usuario informar com 2 if ( Ano < 100 ) { if (Ano > 40 ) Ano += 1900 else Ano += 2000; e.value = strDia+'/'+strMes+'/'+Ano; } if ((Dia<1) || (Dia>31) || isNaN(Dia)) { Msg = Msg + 'Dia '+Dia+' inválido\n'; Erro = true; } if ((Mes<1) || (Mes>12) || isNaN(Mes)) { Msg = Msg + 'Mês '+Mes+' inválido\n'; Erro = true; } if (isNaN(Ano)) { Msg = Msg + 'Ano '+Ano+' inválido\n'; Erro = true; } if ((Dia>=31) && ((Mes==4) || (Mes==6) || (Mes==9) || (Mes==11))) { Msg = Msg + 'Dia inválido para este mês\n'; Erro = true; } if (Mes==2) { //MES DE FEVEREIRO if (Dia>=30) { Msg = Msg + 'Dia inválido para fevereiro\n'; Erro = true; } if ((Dia==29) && (((Ano % 4) != 0) || (((Ano % 100) == 0) && ((Ano % 400) != 0)))) { Msg = Msg + 'Dia inválido para fevereiro. '+ Ano +' não é bisexto\n'; Erro = true; } } } if ( Erro ) { alert(Msg +'Informe a data no formato DD/MM/YYYY\nExemplo:13/11/2005' ); e.focus(); } return true; } function FormataData(e) { var s = ""; s = FiltraCampo(e.value); tam = s.length; r = s.substring(0,2) + "/" + s.substring(2,4) + "/"; r+= s.substring(4,8); if ( tam < 3 ) s = r.substring(0,tam); else if ( tam < 5 ) s = r.substring(0,tam+1); else s = r.substring(0,tam+2); e.value = s; return s; } ///// Checagem de Data e Hora 23/08/2004 function DataHoraOk(e) { var strDia=""; var strMes=""; var strAno=""; var strHora=""; var strMin=""; var Dia=0; var Mes=0; var Ano=0; var Min=0 var Hora=0; var Texto=""; //VALOR A SER TESTADO var Msg=""; // MENSAGEM A SER EXIBIDA NA TELA SE HOUVER ERRO var Erro = false; Texto = FormataDataHora(e); // COLOCAR AS BARRAS //alert (Texto.length); if (Texto!="") { //EXISTE VALOR // DATA ESTÁ DIGITADA INCOMPLETA if ( Texto.length <= 10 && Texto.length != 16) { e.value=''; //alert ('Insira horas'); Msg = Msg + 'Insira horas\n'; Erro = true; //return true; } strDia = Texto.substring(0,2); strMes = Texto.substring(3,5); if (Texto.length != 16) { strAno = Texto.substring(6); } else { strAno = Texto.substring(6,10); strHora = Texto.substring(11,13); strMin = Texto.substring(14,16); Hora=parseInt(strHora,10); Min=parseInt(strMin,10); } Dia=parseInt(strDia,10); Mes=parseInt(strMes,10); Ano=parseInt(strAno,10); //alert (strMin); // colocar o ano com 4 digitos se o usuario informar com 2 if ( Ano < 100 ) { if (Ano > 40 ) Ano += 1900 else Ano += 2000; if (Texto.length != 16) { e.value = strDia+'/'+strMes+'/'+Ano; } else { e.value = strDia+'/'+strMes+'/'+Ano+ '-' +strHora+ ':'+strMin; } } //alert (Min); if ((Dia<1) || (Dia>31) || isNaN(Dia)) { Msg = Msg + 'Dia '+Dia+' inválido\n'; Erro = true; } if ((Mes<1) || (Mes>12) || isNaN(Mes)) { Msg = Msg + 'Mês '+Mes+' inválido\n'; Erro = true; } if (isNaN(Ano)) { Msg = Msg + 'Ano '+Ano+' inválido\n'; Erro = true; } if ((Dia>=31) && ((Mes==4) || (Mes==6) || (Mes==9) || (Mes==11))) { Msg = Msg + 'Dia inválido para este mês\n'; Erro = true; } if (Mes==2) { //MES DE FEVEREIRO if (Dia>=30) { Msg = Msg + 'Dia inválido para fevereiro\n'; Erro = true; } if ((Dia==29) && (((Ano % 4) != 0) || (((Ano % 100) == 0) && ((Ano % 400) != 0)))) { Msg = Msg + 'Dia inválido para fevereiro. '+ Ano +' não é bisexto\n'; Erro = true; } } } if (Hora>24) { Msg=Msg + 'Hora:' +Hora + ' Horas Errada\n'; Erro=true; } if (Min>60) { Msg= Msg + 'Minuto:' + Min+ ' Minuto Errado\n'; Erro=true; } if (Erro) { e.select(); alert(Msg +'Informe a data e hora no formato DD/MM/YYYY hh:mm\nExemplo:13/11/2005 13:11'); e.focus(); return false; } return true; } function FiltraCampo(codigo) { var s = ""; tam = codigo.length; for (i = 0; i < tam ; i++) { if (codigo.substring(i,i + 1) == "0" || codigo.substring(i,i + 1) == "1" || codigo.substring(i,i + 1) == "2" || codigo.substring(i,i + 1) == "3" || codigo.substring(i,i + 1) == "4" || codigo.substring(i,i + 1) == "5" || codigo.substring(i,i + 1) == "6" || codigo.substring(i,i + 1) == "7" || codigo.substring(i,i + 1) == "8" || codigo.substring(i,i + 1) == "9" ) s = s + codigo.substring(i,i + 1); } return s; } function FormataDataHora(e) { var s = ""; s = FiltraCampo(e.value); tam = s.length; //if (tam == 6) { // r = s.substring(0,2) + "/" + s.substring(2,4) + "/"; // r+= s.substring(4,8); // } else { r = s.substring(0,2) + "/" + s.substring(2,4) + "/"; r+= s.substring(4,8) + " " + s.substring(8,10); r+= ":" + s.substring(10,12) // } if ( tam < 3 ) s = r.substring(0,tam); else if ( tam < 5 ) s = r.substring(0,tam+1); else if ( tam < 9 ) s = r.substring(0,tam+2); else if ( tam < 11 ) s = r.substring(0,tam+3); else s = r.substring(0,tam+4); e.value = s; return s; } function dasabilitarenter() { var tecla = event.keyCode; teclan = ""; ver = navigator.appVersion; len = ver.length; for(iln = 0; iln < len; iln++) if (ver.charAt(iln) == "(") break; teclan = (ver.charAt(iln+1).toUpperCase() != "C"); //alert (teclan); if (tecla == 13 ) { return false; } return tecla; } // checagem de cpf function DvCpfOk(e) { var dv = false; controle = ""; s = FiltraCampo(e.value); tam = s.length; if ( tam == 11 ) { dv_cpf = s.substring(tam-2,tam); for ( i = 0; i < 2; i++ ) { soma = 0; for ( j = 0; j < 9; j++ ) soma += s.substring(j,j+1)*(10+i-j); if ( i == 1 ) soma += digito * 2; digito = (soma * 10) % 11; if ( digito == 10 ) digito = 0; controle += digito; } if ( controle == dv_cpf ) dv = true; if ( ! dv && tam > 0) { mensagem = " Erro de digitação:\n"; mensagem+= " ===============\n\n"; mensagem+= " O CPF: " + e.value + " não existe!!\n"; mensagem+= " O DV: " + controle + "\n"; alert(mensagem); e.focus(); } } else { e.value = ''; } return dv; } function FormataCpf(e) { var s = ""; s = FiltraCampo(e.value); tam = s.length; r = s.substring(0,3) + "." + s.substring(3,6) + "." + s.substring(6,9) r += "-" + s.substring(9,11); if ( tam < 4 ) s = r.substring(0,tam); else if ( tam < 7 ) s = r.substring(0,tam+1); else if ( tam < 10 ) s = r.substring(0,tam+2); else s = r.substring(0,tam+3); e.value = s; return s; } // checagem de cnpj function FormataCnpj(e) { var s = ""; var r = ""; s = FiltraCampo(e.value); tam = s.length; r = s.substring(0,2) + "." + s.substring(2,5) + "." + s.substring(5,8) r += "/" + s.substring(8,12) + "-" + s.substring(12,14); if ( tam < 3 ) s = r.substring(0,tam); else if ( tam < 6 ) s = r.substring(0,tam+1); else if ( tam < 9 ) s = r.substring(0,tam+2); else if ( tam < 13 ) s = r.substring(0,tam+3); else s = r.substring(0,tam+4); e.value = s; return s; } function DvCnpjOk(e) { var dv = false; controle = ""; s = FiltraCampo(e.value); tam = s.length if ( tam == 14 ) { dv_cnpj = s.substring(tam-2,tam); for ( i = 0; i < 2; i++ ) { soma = 0; for ( j = 0; j < 12; j++ ) soma += s.substring(j,j+1)*((11+i-j)%8+2); if ( i == 1 ) soma += digito * 2; digito = 11 - soma % 11; if ( digito > 9 ) digito = 0; controle += digito; } if ( controle == dv_cnpj ) dv = true; if ( ! dv && tam > 0) { mensagem = " Erro de digitação:\n"; mensagem+= " ===============\n\n"; mensagem+= " O CNPJ: " + e.value + " não existe!!\n"; mensagem+= " CONTROLE " +controle +"\n"; alert(mensagem); e.focus(); } } else { e.value = ''; } return dv; } //checagem cnpj e cpf function DvCpfCnpjOk(e) { var s = ""; s = FiltraCampo( e.value ); tam = s.length; if ( tam < 12 ) DvCpfOk(e); else DvCnpjOk(e); } function FormataCpfCnpj(e) { var s = ""; s = FiltraCampo(e.value); tam = s.length; if (tam < 12 ) { FormataCpf(e) } else { FormataCnpj(e); } } // checagen fone e fax function FormataFoneFax(e) { var s = ""; var res = ""; s = FiltraCampo(e.value); while ( s.substring(0,1) == "0" ) { s1 = s.substring(1,s.length); s = s1; } // if ( s.length == 14 || s.length == 12 ) // s = s.substring(s.length-10,s.length); // if ( s.length == 13 || s.length == 11 ) // s = s.substring(s.length-9,s.length); res = s.substring(s.length-4,s.length); if ( s.length > 4 && s.length < 9 ) res = s.substring(0,s.length-4)+"-"+res; if ( s.length > 8 ) res = "(" + s.substring(0,2) + ") " + s.substring(2,s.length-4) + "-" + res; e.value = res; return res; } function excluir(link) { if (confirm ("Deseja excluir registro.")) document.location = link } function HabExercicio(){ situacao=document.formcgee_exercicio.exe_situacao.value; if (situacao == "Concluido" || situacao == "Prorrogado" || situacao == "Suspenso" || situacao == "Adiado" || situacao == "Cancelado" ) { var campo = eval("document.formcgee_exercicio.exe_data_fim.disabled=false"); document.formcgee_exercicio.exe_data_fim.className="field_in"; document.formcgee_exercicio.exe_data_fim.select(); document.formcgee_exercicio.exe_data_fim.focus(); } else { var campo = eval("document.formcgee_exercicio.exe_data_fim.disabled=true"); document.formcgee_exercicio.exe_data_fim.className="field_in3"; document.formcgee_exercicio.exe_data_fim.value=""; } } function HabAtividade() { situacao=document.formcgee_atividades.ati_situacao.value; if (situacao == "Concluida" || situacao == "Prorrogada" || situacao == "Suspensa" || situacao == "Adiada" || situacao == "Cancelada" || situacao == "Concluido" || situacao == "Prorrogado" || situacao == "Suspenso" || situacao == "Adiado" || situacao == "Cancelado" ) { //if (situacao == "Concluido" || situacao == "Prorrogado") { var campo = eval("document.formcgee_atividades.ati_data_fim.disabled=false"); document.formcgee_atividades.ati_data_fim.className="field_in"; document.formcgee_atividades.ati_data_fim.select(); document.formcgee_atividades.ati_data_fim.focus(); } else { var campo = eval("document.formcgee_atividades.ati_data_fim.disabled=true"); document.formcgee_atividades.ati_data_fim.className="field_in3"; document.formcgee_atividades.ati_data_fim.value=""; } } function Checar(form) { //cont= form.elements.length -3; //for (var i=0; i < cont; i++){ // if(form.elements[i].value==""){ // alert("Existem campos que devem ser preenchidos!"); // return false; // } // } if (form.name == "formcgee_exercicio") { dtPrev=document.formcgee_exercicio.exe_data_prev.value.split("/"); dtPrev= dtPrev[2] + dtPrev[1]+dtPrev[0]; dtInicio=document.formcgee_exercicio.exe_data_inicio.value.split("/"); dtInicio= dtInicio[2] + dtInicio[1]+dtInicio[0]; dtFim=document.formcgee_exercicio.exe_data_fim.value.split("/"); dtFim= dtFim[2] + dtFim[1]+dtFim[0]; //dtPrev=document.formcgee_exercicio.exe_data_prev.value; //dtInicio=document.formcgee_exercicio.exe_data_inicio.value; //dtFim=document.formcgee_exercicio.exe_data_fim.value; if ( dtInicio > dtPrev) { alert ("Data Prevista esta anterior a data de Inicio"); document.formcgee_exercicio.exe_data_prev.select(); document.formcgee_exercicio.exe_data_prev.focus(); return false; } if ((dtFim!="")){ if ( dtInicio > dtFim) { alert ("Data final esta anterior a data de Inicio"); document.formcgee_exercicio.exe_data_fim.select(); document.formcgee_exercicio.exe_data_fim.focus(); return false; } } } else if(form.name == "formcgee_atividades"){ dtInicioExe=document.formcgee_atividades.exe_data_inicio.value.split("-"); dtInicioExe=dtInicioExe[0] + dtInicioExe[1]+ dtInicioExe[2]; dtFimExe=document.formcgee_atividades.exe_data_fim.value.split("-"); dtFimExe=dtFimExe[0] + dtFimExe[1]+ dtFimExe[2]; dtPrev=document.formcgee_atividades.ati_data_prev.value.split("/"); dtPrev= dtPrev[2] + dtPrev[1]+dtPrev[0]; dtInicio=document.formcgee_atividades.ati_data_inicio.value.split("/"); dtInicio= dtInicio[2] + dtInicio[1]+dtInicio[0]; dtFim=document.formcgee_atividades.ati_data_fim.value.split("/"); dtFim= dtFim[2] + dtFim[1]+dtFim[0]; if ( dtFimExe < dtInicio && dtFimExe != 0) { alert ("Data Inicio esta posterior a data encerramento do Exercicio"); document.formcgee_atividades.ati_data_inicio.select(); document.formcgee_atividades.ati_data_inicio.focus(); return false; } if ( dtFimExe < dtPrev && dtFimExe != 0) { alert ("Data Prevista esta posterior a data encerramento do Exercicio"); document.formcgee_atividades.ati_data_prev.select(); document.formcgee_atividades.ati_data_prev.focus(); return false; } if ( dtFimExe < dtFim && dtFimExe != 0) { alert ("Data fim esta posterior a data encerramento do Exercicio"); document.formcgee_atividades.ati_data_fim.select(); document.formcgee_atividades.ati_data_fim.focus(); return false; } if ( dtInicioExe > dtInicio) { alert ("Data Inicio esta anterior a data do Exercicio"); document.formcgee_atividades.ati_data_inicio.select(); document.formcgee_atividades.ati_data_inicio.focus(); return false; } if ( dtInicio > dtPrev) { alert ("Data Prevista esta anterior a data de Inicio"); document.formcgee_atividades.ati_data_prev.select(); document.formcgee_atividades.ati_data_prev.focus(); return false; } sit=document.formcgee_exercicio.exe_situacao.value; if (dtFim != "NaN") { if ( dtInicio > dtFim) { alert ("Data final esta anterior a data de Inicio"); document.formcgee_atividades.ati_data_fim.select(); document.formcgee_atividades.ati_data_fim.focus(); return false; } } else if (sit != 0){ alert ("Data final em branco"); document.formcgee_atividades.ati_data_fim.select(); document.formcgee_atividades.ati_data_fim.focus(); return false; } } } function FormataReais(fld, milSep, decSep, e) { var sep = 0; var key = ''; var i = j = 0; var len = len2 = 0; var strCheck = '0123456789'; var aux = aux2 = ''; var whichCode = (window.Event) ? e.which : e.keyCode; if (whichCode == 13) return true; key = String.fromCharCode(whichCode); // Valor para o código da Chave if (strCheck.indexOf(key) == -1) return false; // Chave inválida len = fld.value.length; for(i = 0; i < len; i++) if ((fld.value.charAt(i) != '0') && (fld.value.charAt(i) != decSep)) break; aux = ''; for(; i < len; i++) if (strCheck.indexOf(fld.value.charAt(i))!=-1) aux += fld.value.charAt (i); aux += key; len = aux.length; if (len == 0) fld.value = ''; if (len == 1) fld.value = '0'+ decSep + '0' + aux; if (len == 2) fld.value = '0'+ decSep + aux; if (len > 2) { aux2 = ''; for (j = 0, i = len - 3; i >= 0; i--) { if (j == 3) { aux2 += milSep; j = 0; } aux2 += aux.charAt(i); j++; } fld.value = ''; len2 = aux2.length; for (i = len2 - 1; i >= 0; i--) fld.value += aux2.charAt(i); fld.value += decSep + aux.substr(len - 2, len); } return false; } function convReal(cur,len) { n='__0123456789'; d=cur.value; l=d.length; r=''; if (l > 0) { z=d.substr(0,l-1); s=''; a=2; for (i=0; i < l; i++) { c=d.charAt(i); if (n.indexOf(c) > a) { a=1; s+=c; }; }; l=s.length; t=len-1; if (l > t) { l=t; s=s.substr(0,t); }; if (l > 2) { r=s.substr(0,l-2)+','+s.substr(l-2,2); } else { if (l == 2) { r='0,'+s; } else { if (l == 1) { r='0,0'+s; }; }; }; if (r == '') { r='0,00'; } else { l=r.length; if (l > 6) { j=l%3; w=r.substr(0,j); wa=r.substr(j,l-j-6); wb=r.substr(l-6,6); if (j > 0) { w+='.'; }; k=(l-j)/3-2; for (i=0; i < k; i++) { w+=wa.substr(i*3,3)+'.'; }; r=w+wb; }; }; }; if (r.length <= len) { //cur.value= 'R$ ' + '' + r; cur.value= r; } else { //cur.value= 'R$ ' + '' + z; cur.value= z; }; return 'ok'; };