function neoCast_ChPage(comboSelect, section, jsSearchString){ url = "conteudo.php?pagina=neocast/list.php&page=" + comboSelect[comboSelect.selectedIndex].value +"§ion="+ section + jsSearchString; ajaxSendRequest('conteudo', url, null); } /*Pesquisa as notícias com o click da tecla Enter*/ function neoCast_SearchByKeyCode(KeyCode, section, classTitulo){ if (KeyCode==13) { event.keyCode=null; ajaxSendRequest('conteudo','conteudo.php?pagina=neocast/list.php&castSearchInput='+document.getElementById('castSearchInput').value+'§ion='+section+'&classTitulo='+classTitulo,null); } } /*Checa o email*/ function isMail(string) { var reg = new RegExp('^([\.a-zA-Z0-9_-]+)@([\.a-zA-Z0-9_-]){1,}[\.]{1,1}[a-zA-Z]{2,3}$'); if (!reg.test(string)) return false; return true; } /*Fim Checa o email*/ /*Tira os espaços em branco*/ function trim(sString) { while (sString.substring(0,1) == ' ') { sString = sString.substring(1, sString.length); } while (sString.substring(sString.length-1, sString.length) == ' ') { sString = sString.substring(0,sString.length-1); } return sString; } /*Fim Tira os espaços em branco*/ /*Validação do formulário de contato*/ function checkFormulario(){ var form = document.getElementById('frSugestoes'); if(trim(form.frNome.value)==""){ alert('Campo Nome vazio!'); form.frNome.focus(); return false; } if(trim(form.frEmail.value)==""){ alert('Campo E-Mail vazio!'); form.frEmail.focus(); return false; } else{ if(!isMail(form.frEmail.value)){ alert('E-Mail inválido!'); form.frEmail.focus(); return false; } } if(trim(form.frDepto.value)==""){ alert('Campo Departamento não selecionado!'); form.frDepto.focus(); return false; } if(trim(form.frMsg.value)==""){ alert('Campo Comentários vazio!'); form.frMsg.focus(); return false; } form.submit(); } function trocaClasse(nome,id) { if (document.getElementById(id)){ troca = document.getElementById(id); troca.className = nome; } } function validaEnquete(form) { var preencheu = false; botoes = form.ID_RESPOSTA.length; for (i=0;i255) { alert(Mensagem + ' incorreto. Por favor, digite novamente.'); return false; } } return true; } var domainArray=domain.match(domainPat); if (domainArray==null) { alert(Mensagem + ' incorreto. Por favor, digite novamente.'); 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(Mensagem + ' incorreto. Por favor, digite novamente.'); return false; } if (len<2) { var errStr=Mensagem + ' incorreto. Por favor, digite novamente.'; alert(errStr); return false; } return true; } function Trim2(Objeto) { var pos = 0; var str = Objeto.value.substring(pos, pos + 1); var cont = 0; var straux = Objeto.value; while ((str == " ") && (cont <= Objeto.value.length)) { pos = pos + 1; straux = Objeto.value.substring(pos, Objeto.value.length); str = Objeto.value.substring(pos, pos + 1); cont = cont + 1; } var String = straux; pos = String.length; str = String.substring(pos - 1, pos); cont = 0; while ((str == " ") && (cont <= String.length)) { pos = pos - 1; straux = String.substring(0, pos); str = String.substring(pos - 1, pos); cont = cont + 1; } return straux; } function retornaNomeCampo(nome) { nome = nome.substring(6, nome.length); nome = nome.replace("_", " "); return nome; } function campoTipo(nom, tp) { if ( tp == "texto" ) { arrTipos = "txt|chr|nom|des"; } else if ( tp == "email" ) { arrTipos = "eml"; } else { tp = ""; } tiposTeste = arrTipos.split("|"); // alert("Testar se " + nom + " é um " + tp + "\nQtd de itens a testar: " + tiposTeste.length); for ( u=0; u < tiposTeste.length; u++ ) { // alert("Teste: " + u + "\n\nSaber se "+ nom+ " contem " + tiposTeste[u] + "\n\nTestando: " + nom.substring(3,6) + " = " + tiposTeste[u]); if ( nom.substring(3,6) == tiposTeste[u] ) { return true; } } return false; } function testaFormulario(obj) { library = obj.elements; totElements = library.length; for ( i=0; i < totElements; i++ ) { if(library[i].type){ if ( library[i].name.substring(0,3) == "nn_" ) { if ( library[i].type == "text" || library[i].type == "textarea" || library[i].type == "file" || library[i].type == "select-one" || library[i].type == "password" ) { if ( campoTipo(library[i].name, "texto") ) { if ( Trim2(library[i]) == "" ) { alert("Por favor, preencha o campo: '" + retornaNomeCampo(library[i].name) + "'."); library[i].focus(); return false; } } else if ( campoTipo(library[i].name, "email") ) { if (!ChecaEmail(library[i].value, retornaNomeCampo(library[i].name)) ) { library[i].focus(); return false; } } // Para adicionar mais um tipo de campo a testar, apenas adicione um elseif igual o acima else { if ( Trim2(library[i]) == "" ) { alert("Por favor, preencha o campo: '" + retornaNomeCampo(library[i].name) + "'."); library[i].focus(); return false; } } } } } } return true; }