Ir para conteúdo
Fórum Script Brasil

sergioy

Membros
  • Total de itens

    5
  • Registro em

  • Última visita

Tudo que sergioy postou

  1. Olá, estive a fazer teste e vi que desta forma só válida se tem 10 digitos intercalados com /. Não tem como validar o formato dd/mm/aaaa e se o ano é bissexto, dia entre 01 a 31 e mês de 01 a 12, é que eu tentei e não consegui fazer isto. Desculpe-me pelo abuso. Abraços Sergio
  2. Bom dia segue o codigo, o problema é se escrevo 30-02-2006 nas 3 datas é validado só a 1ª data, se escrevo 28-02-2006 na 1ª data e 30-02-2006 nas outras duas não acusa o erro. Abraços Sergio <?php require_once('../Connections/conn_sql0256.php'); ?> <%@LANGUAGE="VBSCRIPT" CODEPAGE="1252"%> <html> <head> <script language="JavaScript" type="text/JavaScript"> <!-- // valida data da matricula function valida_data_matric(){ if(event.keyCode<48 || event.keyCode>57) event.returnValue=false; if(document.Avaliacao.a08_Dt_matricula.value.length==2 || document.Avaliacao.a08_Dt_matricula.value.length==5) document.Avaliacao.a08_Dt_matricula.value+="/" } function maxlength1(){ array_mes=["02","04","06","09","11"]; erro= "Data matricula Inválida" dia=document.Avaliacao.a08_Dt_matricula.value.charAt(0)+document.Avaliacao.a08_Dt_matricula.value.charAt(1); mês=document.Avaliacao.a08_Dt_matricula.value.charAt(3)+document.Avaliacao.a08_Dt_matricula.value.charAt(4); year=document.Avaliacao.a08_Dt_matricula.value.charAt(6)+document.Avaliacao.a08_Dt_matricula.value.charAt(7)+document.Avaliacao.a08_Dt_matricula.value.charAt(8)+document.Avaliacao.a08_Dt_matricula.value.charAt(9); if(document.Avaliacao.a08_Dt_matricula.value.length<10){ alert(erro); document.Avaliacao.a08_Dt_matricula.value=""; document.Avaliacao.a08_Dt_matricula.focus(); return false; } // alert(' data de nascimento = '); // alert(document.Informacoes.a08_Dt_Nasc); texto=document.Avaliacao.a08_Dt_matricula.value; if(parseInt(texto.substr(6,10)) % 4==0) ano="bissexto"; else ano=""; if (dia<1 || dia>31 || mês<1 || mês>12){ alert(erro); document.Avaliacao.a08_Dt_matricula.value=""; document.Avaliacao.a08_Dt_matricula.focus(); return false; } for(x=0; x<array_mes.length; x++){ if(mês == array_mes[x] && dia>30){ alert(erro) document.Avaliacao.a08_Dt_matricula.value=""; document.Avaliacao.a08_Dt_matricula.focus(); return false; } } if (ano!="bissexto" && dia>28 && mês==2){ alert(erro) document.Avaliacao.a08_Dt_matricula.value=""; document.Avaliacao.a08_Dt_matricula.focus(); return false; } if (year<1900){ // alert(year) alert(erro) document.Avaliacao.a08_Dt_matricula.value=""; document.Avaliacao.a08_Dt_matricula.focus(); return false; } nova=document.Avaliacao.a08_Dt_matricula.value.charAt(6)+document.Avaliacao.a08_Dt_matricula.value.charAt(7)+ document.Avaliacao.a08_Dt_matricula.value.charAt(8)+document.Avaliacao.a08_Dt_matricula.value.charAt(9)+"-"+ document.Avaliacao.a08_Dt_matricula.value.charAt(3)+document.Avaliacao.a08_Dt_matricula.value.charAt(4)+"-"+ document.Avaliacao.a08_Dt_matricula.value.charAt(0)+document.Avaliacao.a08_Dt_matricula.value.charAt(1); // alert(' nova data aaaa-mm-dd = ' + nova); document.Avaliacao.a08_Dt_matricula2.value = nova; // alert(' data de nascimento2 = '); // alert(document.Informacoes.a08_Dt_Nasc2); } //--> </script> <script language="JavaScript" type="text/JavaScript"> <!-- // valida data de inspeccao function valida_data_insp(){ if(event.keyCode<48 || event.keyCode>57) event.returnValue=false; if(document.Avaliacao.a22_Dt_Inspeccao.value.length==2 || document.Avaliacao.a22_Dt_Inspeccao.value.length==5) document.Avaliacao.a22_Dt_Inspeccao.value+="/" } function maxlength2(){ array_mes2=["02","04","06","09","11"]; erro2= "Data inspeccao Inválida" dia2=document.Avaliacao.a22_Dt_Inspeccao.value.charAt(0)+document.Avaliacao.a22_Dt_Inspeccao.value.charAt(1); mes2=document.Avaliacao.a22_Dt_Inspeccao.value.charAt(3)+document.Avaliacao.a22_Dt_Inspeccao.value.charAt(4); year2=document.Avaliacao.a22_Dt_Inspeccao.value.charAt(6)+document.Avaliacao.a22_Dt_Inspeccao.value.charAt(7)+document.Avaliacao.a22_Dt_Inspeccao.value.charAt(8)+document.Avaliacao.a22_Dt_Inspeccao.value.charAt(9); if(document.Avaliacao.a22_Dt_Inspeccao.value.length<10){ alert(erro2); document.Avaliacao.a22_Dt_Inspeccao.value=""; document.Avaliacao.a22_Dt_Inspeccao.focus(); return false; } // alert(' data de nascimento = '); // alert(document.Informacoes.a08_Dt_Nasc); texto2=document.Avaliacao.a22_Dt_Inspeccao.value; if(parseInt(texto2.substr(6,10)) % 4==0) ano2="bissexto"; else ano2=""; if (dia2<1 || dia2>31 || mes2<1 || mes2>12){ alert(erro2); document.Avaliacao.a22_Dt_Inspeccao.value=""; document.Avaliacao.a22_Dt_Inspeccao.focus(); return false; } for(x=0; x<array_mes2.length; x++){ if(mes2 == array_mes2[x] && dia2>30){ alert(erro2) document.Avaliacao.a22_Dt_Inspeccao.value=""; document.Avaliacao.a22_Dt_Inspeccao.focus(); return false; } } if (ano2!="bissexto" && dia2>28 && mes2==2){ alert(erro2) document.Avaliacao.a22_Dt_Inspeccao.value=""; document.Avaliacao.a22_Dt_Inspeccao.focus(); return false; } if (year2<1900){ // alert(year2) alert(erro2) document.Avaliacao.a22_Dt_Inspeccao.value=""; document.Avaliacao.a22_Dt_Inspeccao.focus(); return false; } nova2=document.Avaliacao.a22_Dt_Inspeccao.value.charAt(6)+document.Avaliacao.a22_Dt_Inspeccao.value.charAt(7)+ document.Avaliacao.a22_Dt_Inspeccao.value.charAt(8)+document.Avaliacao.a22_Dt_Inspeccao.value.charAt(9)+"-"+ document.Avaliacao.a22_Dt_Inspeccao.value.charAt(3)+document.Avaliacao.a22_Dt_Inspeccao.value.charAt(4)+"-"+ document.Avaliacao.a22_Dt_Inspeccao.value.charAt(0)+document.Avaliacao.a22_Dt_Inspeccao.value.charAt(1); // alert(' nova2 data aaaa-mm-dd = ' + nova2); document.Avaliacao.a22_Dt_Inspeccao2.value = nova2; // alert(' data de nascimento2 = '); // alert(document.Informacoes.a08_Dt_Nasc2); } //--> </script> <script language="JavaScript" type="text/JavaScript"> <!-- // valida data de nascimento function valida_data_nasc(){ if(event.keyCode<48 || event.keyCode>57) event.returnValue=false; if(document.Avaliacao.a45_Dt_Nasc.value.length==2 || document.Avaliacao.a45_Dt_Nasc.value.length==5) document.Avaliacao.a45_Dt_Nasc.value+="/" } function maxlength3(){ array_mes3=["02","04","06","09","11"]; erro3= "Data de nascimento Inválida" dia3=document.Avaliacao.a45_Dt_Nasc.value.charAt(0)+document.Avaliacao.a45_Dt_Nasc.value.charAt(1); mes3=document.Avaliacao.a45_Dt_Nasc.value.charAt(3)+document.Avaliacao.a45_Dt_Nasc.value.charAt(4); year3=document.Avaliacao.a45_Dt_Nasc.value.charAt(6)+document.Avaliacao.a45_Dt_Nasc.value.charAt(7)+document.Avaliacao.a45_Dt_Nasc.value.charAt(8)+document.Avaliacao.a45_Dt_Nasc.value.charAt(9); if(document.Avaliacao.a45_Dt_Nasc.value.length<10){ alert(erro); document.Avaliacao.a45_Dt_Nasc.value=""; document.Avaliacao.a45_Dt_Nasc.focus(); return false; } // alert(' data de nascimento = '); // alert(document.Informacoes.a08_Dt_Nasc); texto3=document.Avaliacao.a45_Dt_Nasc.value; if(parseInt(texto3.substr(6,10)) % 4==0) ano3="bissexto"; else ano3=""; if (dia3<1 || dia3>31 || mes3<1 || mes3>12){ alert(erro3); document.Avaliacao.a45_Dt_Nasc.value=""; document.Avaliacao.a45_Dt_Nasc.focus(); return false; } for(x=0; x<array_mes3.length; x++){ if(mes3 == array_mes3[x] && dia3>30){ alert(erro3) document.Avaliacao.a45_Dt_Nasc.value=""; document.Avaliacao.a45_Dt_Nasc.focus(); return false; } } if (ano3!="bissexto" && dia3>28 && mes3==2){ alert(erro3) document.Avaliacao.a45_Dt_Nasc.value=""; document.Avaliacao.a45_Dt_Nasc.focus(); return false; } if (year3<1900){ // alert(year3) alert(erro3) document.Avaliacao.a45_Dt_Nasc.value=""; document.Avaliacao.a45_Dt_Nasc.focus(); return false; } nova3=document.Avaliacao.a45_Dt_Nasc.value.charAt(6)+document.Avaliacao.a45_Dt_Nasc.value.charAt(7)+ document.Avaliacao.a45_Dt_Nasc.value.charAt(8)+document.Avaliacao.a45_Dt_Nasc.value.charAt(9)+"-"+ document.Avaliacao.a45_Dt_Nasc.value.charAt(3)+document.Avaliacao.a45_Dt_Nasc.value.charAt(4)+"-"+ document.Avaliacao.a45_Dt_Nasc.value.charAt(0)+document.Avaliacao.a45_Dt_Nasc.value.charAt(1); // alert(' nova3 data aaaa-mm-dd = ' + nova3); document.Avaliacao.a45_Dt_Nasc2.value = nova3; } //--> </script> <script language="JavaScript" type="text/JavaScript"> <!-- function MM_reloadPage(init) { //reloads the window if Nav4 resized if (init==true) with (navigator) {if ((appName=="Netscape")&&(parseInt(appVersion)==4)) { document.MM_pgW=innerWidth; document.MM_pgH=innerHeight; onresize=MM_reloadPage; }} else if (innerWidth!=document.MM_pgW || innerHeight!=document.MM_pgH) location.reload(); } MM_reloadPage(true); function MM_preloadImages() { //v3.0 var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array(); var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++) if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}} } //--> </script> <script src="../Scripts/AC_RunActiveContent.js" type="text/javascript"></script> <script src="../Scripts/AC_ActiveX.js" type="text/javascript"></script> </head> <body background="imagens/fundo.gif" leftmargin="0" topmargin="2" marginwidth="0" marginheight="0"> <table width="95%" height="99%" border="0" align="center" cellpadding="0" cellspacing="0" bgcolor="#FFFFFF"> <tr> <td height="25" colspan="3"><table width="100%" height="25" border="0" cellpadding="0" cellspacing="0"> <tr> <td width="25"><img src="imagens/canto1.gif" width="25" height="25"></td> <td valign="top"><table width="100%" height="3" border="0" cellpadding="0" cellspacing="0" bgcolor="#517CA0" class="contorno"> <tr> <td valign="top">&nbsp;</td> </tr> </table> <a name="inicio"></a></td> <td width="25"><img src="imagens/canto2.gif" width="25" height="25"></td> </tr> </table> </td> </tr> <tr> <td width="5" class="contorno1">&nbsp;</td> <td valign="top"><table width="99%" border="0" cellspacing="0" cellpadding="0"> <tr> <td width="750" valign="top"> <script type="text/javascript"> AC_FL_RunContent('codebase','http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,29,0','width','750','height','90','src','menu/menu','menu','false','quality','high','pluginspage','http://www.macromedia.com/go/getflashplayer','movie','menu/menu' ); //end AC code </script> <noscript> <object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,29,0" name="menu" width="750" height="90" id="menu"> <param name="movie" value="menu/menu.swf"> <param name="quality" value="high"> <embed src="menu/menu.swf" width="750" height="90" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" name="menu" swliveconnect="true"></embed> </object> </noscript> </td> </tr> </table> <table width="100%" height="100%" border="0" cellpadding="0" cellspacing="0"> <tr> <td width="160" align="center" valign="top" background="imagens/esq2.gif">&nbsp; </td> <td valign="top"><table width="98%" border="0" align="center" cellpadding="0" cellspacing="0"> <tr> <td> <form action="avaliesm.php" name="Avaliacao" method="POST" OnSubmit="return maxlength1(); return maxlength2(); return maxlength3()"> <br> <br> <table width="98%" border="0" align="center" cellpadding="0" cellspacing="0" class="formtop"> <tr> <td>Avaliar viatura</td> </tr> </table> <table width="98%" border="0" align="center" cellpadding="0" cellspacing="0" class="formborder"> <tr> <td height="14"><table width="95%" border="0" align="center" cellpadding="0" cellspacing="0" class="formtexto"> </table></td> </tr> <tr> <td><table width="95%" border="0" align="center" cellpadding="0" cellspacing="0" class="formtexto"> <tr> <td>&nbsp;</td> <td>&nbsp;</td> <td width="18%">&nbsp;</td> <td width="34%">&nbsp;</td> </tr> <tr bgcolor="#0099FF"> <td colspan="4"><div align="left"><font color="#FFFFFF"><strong>Dados da Sua Viatura</strong></font></div> <div align="center"></div></td> </tr> <tr> <td width="16%">&nbsp;</td> <td width="32%">&nbsp; </td> <td>Dt Matricula</td> <td><input name="a08_Dt_matricula" type="text" class="formcaixa" id="a08_Dt_matricula" size="10" maxlength="10" onkeypress="valida_data_matric()"> (dd/mm/aaaa) <input name="a08_Dt_matricula2" type="hidden" class="formcaixa" id="a08_Dt_matricula2" size="10" maxlength="10"></td> </tr> </table> <table width="95%" border="0" align="center" cellpadding="0" cellspacing="0" class="formtexto"> <tr bgcolor="#0099FF"> <td colspan="3"><div align="left"><font color="#FFFFFF"><strong>Estado da Viatura</strong></font></div> <div align="center"></div></td> </tr> <tr> <td width="30%">&nbsp;</td> <td width="39%">&nbsp;</td> <td width="22%">&nbsp;</td> </tr> <tr> <td>Data de inspec&ccedil;&atilde;o</td> <td><input name="a22_Dt_Inspeccao" type="text" class="formcaixa" id="a22_Dt_Inspeccao" size="10" maxlength="10" onkeypress="valida_data_insp()"> (dd/mm/aaaa) <input name="a22_Dt_Inspeccao2" type="hidden" class="formcaixa" id="a22_Dt_Inspeccao2" size="10" maxlength="10"></td> <td>&nbsp;</td> </tr> <tr> <td>&nbsp;</td> <td>&nbsp;</td> <td>&nbsp;</td> </tr> </table> <table width="95%" border="0" align="center" cellpadding="0" cellspacing="0" class="formtexto"> <tr bgcolor="#0099FF"> <td><font color="#FFFFFF"><strong>Equipamentos Opcionais</strong></font></td> </tr> </table> <table width="95%" border="0" align="center" cellpadding="0" cellspacing="0" class="formtexto"> <tr> <td width="100%"><div align="left"> </div> <div align="center"></div></td> </tr> </table> <table width="95%" border="0" align="center" cellpadding="0" cellspacing="1" class="formtexto"> <tr bgcolor="#0099FF"> <td colspan="3" valign="middle"><font color="#FFFFFF">Dados Pessoais</font></td> </tr> <tr> <td width="12%" valign="middle">&nbsp;</td> <td colspan="2">&nbsp;</td> </tr> <tr> <td> Dt.Nasc.</td> <td colspan="2"><input name="a45_Dt_Nasc" type="text" class="formcaixa" id="a45_Dt_Nasc" size="10" maxlength="10" onkeypress="valida_data_nasc()"> (dd/mm/aaaa) <input name="a45_Dt_Nasc2" type="hidden" class="formcaixa" id="a45_Dt_Nasc2" size="10" maxlength="10"> </td> </tr> <tr> <td>&nbsp;</td> <td width="37%" valign="middle"> <div align="right"> <input type="submit" class="formbotao" value="Enviar"> </div></td> <td width="51%" valign="middle"> <font size="2" face="Arial, Helvetica, sans-serif"> <input name="Limpar" type="reset" class="formbotao" id="Limpar" value="Limpar"> </font></td> </tr> </table> </td> </tr> <tr> <td>&nbsp;</td> </tr> </table> </form> </td> </tr> </table></td> <td width="140" valign="top" background="imagens/publici2.jpg"> <table width="100%" border="0" cellpadding="0" cellspacing="0"> <tr> <td width="10">&nbsp;</td> <td width="130" valign="top"> <iframe src="publicidade.html" name="Publicidade" width="130" marginwidth="0" height="350" marginheight="0" align="top" scrolling="no" frameborder="0" class="iframepubli" ></iframe> </td> </tr> </table> </td> </tr> </table></td> <td width="5" align="right" class="contorno1">&nbsp;</td> </tr> <tr> <td height="25" colspan="3"><table width="100%" height="25" border="0" cellpadding="0" cellspacing="0"> <tr> <td width="25"><img src="imagens/canto31.gif" width="25" height="25"></td> <td valign="bottom"><table width="100%" height="25" border="0" cellpadding="0" cellspacing="0"> <tr> <td width="140" valign="bottom" background="imagens/esq3.gif"><table width="100%" border="0" cellpadding="0" cellspacing="0" class="contorno"> <tr> <td>&nbsp;</td> </tr> </table></td> <td valign="bottom"><table width="100%" border="0" cellpadding="0" cellspacing="0" class="contorno"> <tr> <td>&nbsp;</td> </tr> </table></td> <td width="120" valign="bottom" background="imagens/publici3.jpg"><div align="right"> </div> <div align="right"> </div> <div align="right"><a href="http://www.sys.com.pt" target="_blank"><img src="imagens/sys.jpg" alt="www.sys.com.pt" width="110" height="16" border="0"></a> </div> <table width="100%" border="0" cellpadding="0" cellspacing="0" class="contorno"> <tr> <td>&nbsp;</td> </tr> </table></td></tr> </table></td> <td width="25"><img src="imagens/canto4.gif" width="25" height="25"></td> </tr> </table> </td> </tr> </table> </body> </html>
  3. Não consigo anexar um ficheiro php? diz que não tenho permissão!!! abraços Sergio
  4. Olá boa tarde, desculpe-me não ter respondido antes, estive de férias e só retornei agora. pode dizer-me como faço par postar o form, que eu não consigo anexá-lo aqui. abraços Sergio
  5. Olá pessoal, tenho 3 datas dentro do mesmo formulario e utilizo tres funções em javascript para validar cada data. O que acontece é que se fosse só uma data funciona, quando coloco para validar as 3 não faz nada. No form action onsubmit "return maxlength1()"; "return maxlength2()"; "return maxlength3()" Será que alguém pode ajudar-me. Obrigado Sergio
×
×
  • Criar Novo...