RaroPixelado Posted July 31, 2011 Report Share Posted July 31, 2011 Oi denovo.. eu gostaria de um script assim: enquanto não for digitado algo numa textarea o buttao ficara inativo (tipo com uma camada branca por cima) Quote Link to comment Share on other sites More sharing options...
0 rplaurindo Posted July 31, 2011 Report Share Posted July 31, 2011 (edited) Primeiramente, crie o button e coloque em sua tag disabled="disabled". Crie o textarea e coloque em sua tag o evento onkeypress="enableButton(this, id)". Agora vamos programar o "enableButton".function enableButton(textObj, id){ var buttonObj = document.getElementById(id); if (txtObj.value != '') buttonObj.disabled = false; else buttonObj.disabled = true; }Teste aí, porque eu não testei. Qualquer dúvida poste aí. Edited July 31, 2011 by Rafael P L Quote Link to comment Share on other sites More sharing options...
0 RaroPixelado Posted July 31, 2011 Author Report Share Posted July 31, 2011 não funcionou ;s Quote Link to comment Share on other sites More sharing options...
0 rplaurindo Posted July 31, 2011 Report Share Posted July 31, 2011 (edited) Eu havia digitado errado. Teste novamente agora. Edited July 31, 2011 by Rafael P L Quote Link to comment Share on other sites More sharing options...
0 RaroPixelado Posted July 31, 2011 Author Report Share Posted July 31, 2011 <script> function enableButton(textObj, id){ var buttonObj = document.getElementById(id); if (txtObj.value != '') buttonObj.disabled = 'false'; else buttonObj.disabled = 'true'; } </script> <input disabled="disabled" type="button" value="Botão"> <textarea onkeypress="enableButton(this, id)" ></textarea>ainda n funciona Quote Link to comment Share on other sites More sharing options...
0 rplaurindo Posted July 31, 2011 Report Share Posted July 31, 2011 (edited) Perdão. Tire as aspas de true e false. Pois são valores booleanos e não strings. Edited July 31, 2011 by Rafael P L Quote Link to comment Share on other sites More sharing options...
0 RaroPixelado Posted July 31, 2011 Author Report Share Posted July 31, 2011 <script>function enableButton(textObj, id){ var buttonObj = document.getElementById(id); if (txtObj.value != '') buttonObj.disabled = false; else buttonObj.disabled = true;}</script><input disabled="disabled" type="button" value="Botão"><textarea onkeypress="enableButton(this, id)" ></textarea>ainda... Quote Link to comment Share on other sites More sharing options...
0 rplaurindo Posted July 31, 2011 Report Share Posted July 31, 2011 (edited) Agora foi.<script type="text/javascript"> function enableButton(txtObj, id) { var buttonObj = document.getElementById(id); if (txtObj.value != '') buttonObj.disabled = false; else buttonObj.disabled = true; } </script> <body> <form> <textarea id="txtTest" onkeyup="enableButton(this, 'btnEnable')"></textarea> <input type="button" id="btnEnable" disabled="disabled"> </form> </body> Edited August 1, 2011 by Rafael P L Quote Link to comment Share on other sites More sharing options...
0 RaroPixelado Posted July 31, 2011 Author Report Share Posted July 31, 2011 Gracias nino ;) você estaria enteresado em entrar num projeto meu? Quote Link to comment Share on other sites More sharing options...
0 rplaurindo Posted July 31, 2011 Report Share Posted July 31, 2011 Cara. Estou muito sem tempo, e vou ficar nos próximos 3 meses. Só após vou estar liberado para participar de algo. Mas me interesso sim, caso ainda precise de mim depois deste tempo.Faça melhor ainda. Use o evento "onkeyup" ao invés de "onkeypress". Ok?! Quote Link to comment Share on other sites More sharing options...
0 RaroPixelado Posted July 31, 2011 Author Report Share Posted July 31, 2011 Táh, n irei poder mas posto minhas duvidas no forum :D Quote Link to comment Share on other sites More sharing options...
Question
RaroPixelado
Oi denovo.. eu gostaria de um script assim: enquanto não for digitado algo numa textarea o buttao ficara inativo (tipo com uma camada branca por cima)
Link to comment
Share on other sites
10 answers to this question
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.