Jump to content


Photo

Js Pra Eu


  • Faça o login para participar
1 reply to this topic

#1 crazybaby

crazybaby

    Cyber Eye

  • Banidos
  • PipPipPipPipPipPipPipPipPip
  • 1112 posts
  • Sexo:Não informado
  • Localidade:Divinopolis-MG
  • Interesses:ASP & Design

Posted 27/09/2003, 17:17

alguem podia fazer um js q valida se os campos desse form foram preenchidos?
plis
valew

<form method="post" action="acao_inserir.asp">
  <table width="39%" border="0" cellspacing="1" cellpadding="1">
    <tr> 
      <td>T&iacute;tulo:</td>
      <td><input type="text" name="txttitulo"></td>
    </tr>
    <tr> 
      <td><p>Link:</p></td>
      <td><input name="txtlink" type="text" size="60"></td>
    </tr>
    <tr> 
      <td>Descri&ccedil;&atilde;o:</td>
      <td><textarea name="txtdescricao" cols="30" rows="5"></textarea></td>
    </tr>
    <tr> 
      <td><input type="submit" name="inserir" value="Inserir"></td>
      <td><input type="reset" name="limpar" value="Limpar"></td>
    </tr>
  </table>
  </form>


#2 Without a Nick

Without a Nick

    Sem culpa no cartório

  • Usuários
  • 2378 posts
  • Sexo:Não informado
  • Localidade:Guarulhos

Posted 27/09/2003, 17:30

Criei este código. Fiz algumas modificações, para melhor funcionamento:

<html>

<head><script language="JavaScript">
<!--
function valida(form) {
var titulo=document.form.txttitulo.value;
var link=document.form.txtlink.value;
var desc=document.form.txtdescricao.value;
if (titulo=="") {
alert("O campo TÍTULO está vazio.");
document.form.txttitulo.focus();
return false;
}
if (link=="") {
alert("O campo LINK está vazio.");
document.form.txtlink.focus();
return false;
}
if (link=="http://") {
alert("A URL não é válida.");
document.form.txtlink.focus();
return false;
}
if (desc=="") {
alert("Falta a descrição.");
document.form.txtdescricao.focus();
return false;
}
return true;
document.form.submit();
}
//-->
</script>
<title>Página</title>
</head>

<body>
<form method="post" action="acao_inserir.asp" name="form" onsubmit="return valida();">
 <table width="39%" border="0" cellspacing="1" cellpadding="1">
   <tr> 
     <td>T&iacute;tulo:</td>
     <td><input type="text" name="txttitulo"></td>
   </tr>
   <tr> 
     <td><p>Link:</p></td>
     <td><input name="txtlink" type="text" size="60" value="http://"></td>
   </tr>
   <tr> 
     <td>Descri&ccedil;&atilde;o:</td>
     <td><textarea name="txtdescricao" cols="30" rows="5"></textarea></td>
   </tr>
   <tr> 
     <td><input type="submit" name="inserir" value="Inserir"></td>
     <td><input type="reset" name="limpar" value="Limpar"></td>
   </tr>
 </table>
 </form>
</body>

</html>





2 user(s) are reading this topic

0 membro(s), 2 visitante(s) e 0 membros anônimo(s)

IPB Skin By Virteq