Ir para conteúdo
Fórum Script Brasil
  • 0

Validar Select...


Husscoffee

Pergunta

Olá pessoal, estou precisando de ajuda, já procurei bastante no fórum mais não encontrei o q estou precisando.

É o seguinte, tenho 4 menus select, gostaria q o formulário fosse validado se pelo menos um deles tivesse selecionado alguma valor, segue abaixo o form:

<html>

<head>

<title>Documento sem t&iacute;tulo</title>

<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">

</head>

<body>

<font color="#FFFFFF" size="2" face="Arial, Helvetica, sans-serif"><strong><font color="#FFFFFF" size="2" face="Arial, Helvetica, sans-serif"><strong><font color="#FFFFFF" size="2" face="Arial, Helvetica, sans-serif"><strong>

</strong></font></strong></font></strong></font>

<form name="orcamento" action="cdonts.asp" method="post">

  <p><font color="#FFFFFF" size="2" face="Arial, Helvetica, sans-serif"><strong><font color="#FFFFFF" size="2" face="Arial, Helvetica, sans-serif"><strong><font color="#FFFFFF" size="2" face="Arial, Helvetica, sans-serif"><strong>

    <select name="menu1">

      <option value=""selected>-----</option>

      <option value="1" >1</option>

      <option value="2">2</option>

      <option value="3">3</option>

      <option value="4">4</option>

      <option value="5">5</option>

      <option value="6">6</option>

      <option value="7">7</option>

      <option value="8">8</option>

      <option value="9">9</option>

      <option value="10">10</option>

      <option value="11">11</option>

      <option value="12">12</option>

      <option value="13">13</option>

      <option value="14">14</option>

      <option value="15">15</option>

      <option value="16">16</option>

      <option value="17">17</option>

      <option value="18">18</option>

      <option value="19">19</option>

      <option value="20">20</option>

    </select>

    </strong></font></strong></font></strong></font></p>

  <p><font color="#FFFFFF" size="2" face="Arial, Helvetica, sans-serif"><strong><font color="#FFFFFF" size="2" face="Arial, Helvetica, sans-serif"><strong><font color="#FFFFFF" size="2" face="Arial, Helvetica, sans-serif"><strong>

    <select name="select">

      <option value=""selected>-----</option>

      <option value="1" >1</option>

      <option value="2">2</option>

      <option value="3">3</option>

      <option value="4">4</option>

      <option value="5">5</option>

      <option value="6">6</option>

      <option value="7">7</option>

      <option value="8">8</option>

      <option value="9">9</option>

      <option value="10">10</option>

      <option value="11">11</option>

      <option value="12">12</option>

      <option value="13">13</option>

      <option value="14">14</option>

      <option value="15">15</option>

      <option value="16">16</option>

      <option value="17">17</option>

      <option value="18">18</option>

      <option value="19">19</option>

      <option value="20">20</option>

    </select>

    </strong></font></strong></font></strong></font></p>

  <p><font color="#FFFFFF" size="2" face="Arial, Helvetica, sans-serif"><strong><font color="#FFFFFF" size="2" face="Arial, Helvetica, sans-serif"><strong><font color="#FFFFFF" size="2" face="Arial, Helvetica, sans-serif"><strong>

    <select name="select2">

      <option value=""selected>-----</option>

      <option value="1" >1</option>

      <option value="2">2</option>

      <option value="3">3</option>

      <option value="4">4</option>

      <option value="5">5</option>

      <option value="6">6</option>

      <option value="7">7</option>

      <option value="8">8</option>

      <option value="9">9</option>

      <option value="10">10</option>

      <option value="11">11</option>

      <option value="12">12</option>

      <option value="13">13</option>

      <option value="14">14</option>

      <option value="15">15</option>

      <option value="16">16</option>

      <option value="17">17</option>

      <option value="18">18</option>

      <option value="19">19</option>

      <option value="20">20</option>

    </select>

    </strong></font></strong></font></strong></font></p>

  <p><font color="#FFFFFF" size="2" face="Arial, Helvetica, sans-serif"><strong><font color="#FFFFFF" size="2" face="Arial, Helvetica, sans-serif"><strong><font color="#FFFFFF" size="2" face="Arial, Helvetica, sans-serif"><strong>

    <select name="select3">

      <option value=""selected>-----</option>

      <option value="1" >1</option>

      <option value="2">2</option>

      <option value="3">3</option>

      <option value="4">4</option>

      <option value="5">5</option>

      <option value="6">6</option>

      <option value="7">7</option>

      <option value="8">8</option>

      <option value="9">9</option>

      <option value="10">10</option>

      <option value="11">11</option>

      <option value="12">12</option>

      <option value="13">13</option>

      <option value="14">14</option>

      <option value="15">15</option>

      <option value="16">16</option>

      <option value="17">17</option>

      <option value="18">18</option>

      <option value="19">19</option>

      <option value="20">20</option>

    </select>

    </strong></font></strong></font></strong></font></p>

  <p><input type="submit" value="Solicitar or&ccedil;amento" name="botao"></p>

</form>

<font color="#FFFFFF" size="2" face="Arial, Helvetica, sans-serif"><strong><font color="#FFFFFF" size="2" face="Arial, Helvetica, sans-serif"><strong><font color="#FFFFFF" size="2" face="Arial, Helvetica, sans-serif"><strong>

</strong></font></strong></font></strong></font>

</body>

</html>

Link para o comentário
Compartilhar em outros sites

2 respostass a esta questão

Posts Recomendados

  • 0

eu testei aqui e funcionou:

<html>

<head>

<title>Documento sem t&iacute;tulo</title>

<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">

</head>

<script language="javascript">

function validarselect(){

if (document.orcamento.menu1.value == "") {

  if (document.orcamento.select.value == "") {

  if (document.orcamento.select2.value == "") {

    if (document.orcamento.select3.value == "") {

    alert("selecione pelo menos 1 combo");

    return false;

    }

  }

  }

} else {

  return true;

}

}

</script>

<body>

<font color="#FFFFFF" size="2" face="Arial, Helvetica, sans-serif"><strong><font color="#FFFFFF" size="2" face="Arial, Helvetica, sans-serif"><strong><font color="#FFFFFF" size="2" face="Arial, Helvetica, sans-serif"><strong>

</strong></font></strong></font></strong></font>

<form name="orcamento" action="cdonts.asp" method="post">

  <p><font color="#FFFFFF" size="2" face="Arial, Helvetica, sans-serif"><strong><font color="#FFFFFF" size="2" face="Arial, Helvetica, sans-serif"><strong><font color="#FFFFFF" size="2" face="Arial, Helvetica, sans-serif"><strong>

    <select name="menu1">

      <option value=""selected>-----</option>

      <option value="1" >1</option>

      <option value="2">2</option>

      <option value="3">3</option>

      <option value="4">4</option>

      <option value="5">5</option>

      <option value="6">6</option>

      <option value="7">7</option>

      <option value="8">8</option>

      <option value="9">9</option>

      <option value="10">10</option>

      <option value="11">11</option>

      <option value="12">12</option>

      <option value="13">13</option>

      <option value="14">14</option>

      <option value="15">15</option>

      <option value="16">16</option>

      <option value="17">17</option>

      <option value="18">18</option>

      <option value="19">19</option>

      <option value="20">20</option>

    </select>

    </strong></font></strong></font></strong></font></p>

  <p><font color="#FFFFFF" size="2" face="Arial, Helvetica, sans-serif"><strong><font color="#FFFFFF" size="2" face="Arial, Helvetica, sans-serif"><strong><font color="#FFFFFF" size="2" face="Arial, Helvetica, sans-serif"><strong>

    <select name="select">

      <option value=""selected>-----</option>

      <option value="1" >1</option>

      <option value="2">2</option>

      <option value="3">3</option>

      <option value="4">4</option>

      <option value="5">5</option>

      <option value="6">6</option>

      <option value="7">7</option>

      <option value="8">8</option>

      <option value="9">9</option>

      <option value="10">10</option>

      <option value="11">11</option>

      <option value="12">12</option>

      <option value="13">13</option>

      <option value="14">14</option>

      <option value="15">15</option>

      <option value="16">16</option>

      <option value="17">17</option>

      <option value="18">18</option>

      <option value="19">19</option>

      <option value="20">20</option>

    </select>

    </strong></font></strong></font></strong></font></p>

  <p><font color="#FFFFFF" size="2" face="Arial, Helvetica, sans-serif"><strong><font color="#FFFFFF" size="2" face="Arial, Helvetica, sans-serif"><strong><font color="#FFFFFF" size="2" face="Arial, Helvetica, sans-serif"><strong>

    <select name="select2">

      <option value=""selected>-----</option>

      <option value="1" >1</option>

      <option value="2">2</option>

      <option value="3">3</option>

      <option value="4">4</option>

      <option value="5">5</option>

      <option value="6">6</option>

      <option value="7">7</option>

      <option value="8">8</option>

      <option value="9">9</option>

      <option value="10">10</option>

      <option value="11">11</option>

      <option value="12">12</option>

      <option value="13">13</option>

      <option value="14">14</option>

      <option value="15">15</option>

      <option value="16">16</option>

      <option value="17">17</option>

      <option value="18">18</option>

      <option value="19">19</option>

      <option value="20">20</option>

    </select>

    </strong></font></strong></font></strong></font></p>

  <p><font color="#FFFFFF" size="2" face="Arial, Helvetica, sans-serif"><strong><font color="#FFFFFF" size="2" face="Arial, Helvetica, sans-serif"><strong><font color="#FFFFFF" size="2" face="Arial, Helvetica, sans-serif"><strong>

    <select name="select3">

      <option value=""selected>-----</option>

      <option value="1" >1</option>

      <option value="2">2</option>

      <option value="3">3</option>

      <option value="4">4</option>

      <option value="5">5</option>

      <option value="6">6</option>

      <option value="7">7</option>

      <option value="8">8</option>

      <option value="9">9</option>

      <option value="10">10</option>

      <option value="11">11</option>

      <option value="12">12</option>

      <option value="13">13</option>

      <option value="14">14</option>

      <option value="15">15</option>

      <option value="16">16</option>

      <option value="17">17</option>

      <option value="18">18</option>

      <option value="19">19</option>

      <option value="20">20</option>

    </select>

    </strong></font></strong></font></strong></font></p>

  <p>

    <input type="submit" value="Solicitar or&ccedil;amento" name="botao"  onClick="return validarselect()">

  </p>

</form>

<font color="#FFFFFF" size="2" face="Arial, Helvetica, sans-serif"><strong><font color="#FFFFFF" size="2" face="Arial, Helvetica, sans-serif"><strong><font color="#FFFFFF" size="2" face="Arial, Helvetica, sans-serif"><strong>

</strong></font></strong></font></strong></font>

</body>

</html>

Link para o comentário
Compartilhar em outros sites

Visitante
Este tópico está impedido de receber novos posts.


  • Estatísticas dos Fóruns

    • Tópicos
      152,3k
    • Posts
      652,3k
×
×
  • Criar Novo...