Olha só, em uma página de cadastro eu criei um campo texto que só é habilitado quando selecionado a opção 'outros' que é um botão 'radio',
eu queria que mostrasse um alert ao enviar caso a opção 'outros' fosse selecionada, e o campo texto permanecesse em branco, obrigando a digitar algo no campo 'assunto'.
Fico grato se alguém puder me ajudar, me dar alguma dica, eu já testei alguns script mas não consegui sucesso...
Pergunta
Daciano
Bom dia Senhores,
Estou precisando de uma ajuda.
Olha só, em uma página de cadastro eu criei um campo texto que só é habilitado quando selecionado a opção 'outros' que é um botão 'radio',
eu queria que mostrasse um alert ao enviar caso a opção 'outros' fosse selecionada, e o campo texto permanecesse em branco, obrigando a digitar algo no campo 'assunto'.
Fico grato se alguém puder me ajudar, me dar alguma dica, eu já testei alguns script mas não consegui sucesso...
colocarei o codigo a baixo...
<link href="css/css.css" rel="stylesheet" type="text/css"> <?php if ($_POST["btenviar"]){ $sltsetor = $_POST[sltsetor]; $sltequipamento = $_POST[sltequipamento]; $txtassunto = $_POST[txtassunto]; $txtdescricao = $_POST[txtdescricao]; $prioridade = $_POST[prioridade]; $txtoutros = $_POST[txtoutros]; $data = date("Y-m-d"); $hora = date("H:i"); if ($txtassunto == '0') {$txtassunto = $txtoutros;}; $sql = ("insert into os(CODSOLICITANTE, CODSETOR, CODEQUIPAMENTO, DATA_ABERTURA, HORA_ABERTURA, ASSUNTO, DESCRICAO, PRIORIDADE) values ('$_SESSION[codnome]','$sltsetor', '$sltequipamento', '$data', '$hora', '$txtassunto', '$txtdescricao', '$prioridade')"); $res = mysql_query($sql) OR die(mysql_error()); echo 'O.S. INSERIDA COM SUCESSO<br><br>'; echo $txtassunto.".<br>".$txtdescricao."<br>"; ?> <a href="principal.php?menu=os">Concluir</a> <?php } else { ?> <script Language="JavaScript"> function validafrmdados() { if ((forminsos.txtassunto.value == 0 ) && (forminsos.txtoutros.value == '' )) { alert('Você deve informar o assunto.'); forminsos.txtoutros.focus(); return (false); } return (true); } </script> <table width="700" border="0" align="center"> <tr> <td height="425"> <form action="" method="post" name="forminsos" id="forminsos"> <table width="700" align="center"> <tr> <td height="20" colspan="2"> <div align="center"><span class="lstmenu">SOLICITANTE</span> <hr align="center" width="700"> </div></td> </tr> <tr> <td height="24"> <div align="right"> </div> <div align="right"></div> <div align="right"></div> <div align="justify">Data Abertura:</div></td> <td height="24"> <?php $data = date("Y-m-d"); $hora = date("H:i"); $novadata = substr($data,8,2). "/" .substr($data,5,2). "/". substr($data,0,4); echo "Data: $novadata - Hora: $hora"; ?> <div align="left"></div></td> </tr> <tr> <td width="124">Nome solicitante:</td> <td width="572"> <?php echo $_SESSION[nome]; ?> </td> </tr> <tr> <td height="28">Setor solicitado:</td> <td><select name="sltsetor" id="sltsetor"> <option value="0" selected>Selecione</option> <?php $sql1 = "SELECT * FROM setor ORDER BY setor"; $resultado1 = mysql_query($sql1) or die ("Setor indisponivel"); while ($linha1=mysql_fetch_array($resultado1)) { ?> <option value="<?php echo $linha1[CODSETOR]; ?>" <?php if ($linha1[CODSETOR] == $linha[CODSETOR]) { echo 'selected';}?>> <?php echo $linha1[SETOR]?> </option>. <?php } //fecha while setor?> </select> </td> </tr> <tr> <td height="25">Assunto:</td> <td><input name="txtassunto" type="radio" value="Equipamentos" checked> Equipamentos <input type="radio" name="txtassunto" value="Planilha/textos"> Planilha/textos <input type="radio" name="txtassunto" value="Internet/e-mail"> Internet/e-mail <input type="radio" name="txtassunto" value="GESTOR"> GESTOR <input name="txtassunto" type="radio" onClick="java script:forminsos.txtoutros.disabled = false; forminsos.txtoutros.focus();" value="0"> Outros</td> </tr> <tr> <td height="29"> </td> <td> <input name="txtoutros" type="text" disabled="true" id="txtoutros" size="30"></td> </tr> <tr> <td height="90">Descrição:</td> <td><textarea name="txtdescricao" cols="70" rows="5" wrap="VIRTUAL" id="txtdescricao"></textarea></td> </tr> <tr> <td height="32">Nº Patrimônio:</td> <td> <select name="sltequipamento" id="sltequipamento"> <option value="" selected>Sem Número</option> <?php $sql3 = "SELECT * FROM equipamento ORDER BY patrimonio"; $resultado3 = mysql_query($sql3) or die ("Setor indisponivel"); while ($linha3=mysql_fetch_array($resultado3)) { ?> <option value="<?php echo $linha3[codequipamento]?>" <?php if ($linha3[codequipamento] == $linha[CODEQUIPAMENTO]) { echo 'selected';}?>> <?php echo $linha3[patrimonio]?> </option>. <?php } //fecha while setor ?> </select> <em><font size="2">>>Se houver problema no equipamento selecione o número de patrimônio! </font></em></td> </tr> <tr> <td height="23" valign="bottom">Prioridade:</td> <td> <hr noshade> <input name="prioridade" type="radio" value="0"checked> Baixa <input type="radio" name="prioridade" value="1"> Média <input type="radio" name="prioridade" value="2"> Urgente </td> </tr> <tr> <td></td> <td></td> </tr> <tr> <td colspan="2"> <input name="enviar" type="submit" id="enviar" onClick="java script:validafrmdados();" value="Enviar"> <input name="btnlimpar" type="reset" id="btnlimpar2" value="Redefinir"> <input name="id" type="hidden" id="id" value="<?php echo $linha[CODOS]?>"> <input type='hidden' name='btenviar' value='1'> </td> </tr> </table> <hr> </form> </td> </tr> </table> <?php } ?>:rolleyes:
Link para o comentário
Compartilhar em outros sites
3 respostass a esta questão
Posts Recomendados
Participe da discussão
Você pode postar agora e se registrar depois. Se você já tem uma conta, acesse agora para postar com sua conta.