Brendo Posted June 1, 2015 Report Share Posted June 1, 2015 (edited) Olá boa tarde, como eu crio um alert de acordo com o texto digitado no <textarea> ex: <textarea id="myTextarea" placeholder="Digite seu nome"> </textarea> <button type="button" onclick="myFunction()">Try it</button></p> <p id="demo"></p> <script> function myFunction() { var x = document.getElementById("myTextarea").value; document.getElementById("demo").innerHTML = x; } if x=Brendo { alert ("Good name!"); else { alert ("Não te conheço!"); } } Edited June 1, 2015 by Brendo Quote Link to comment Share on other sites More sharing options...
0 Rnl Rula Posted June 2, 2015 Report Share Posted June 2, 2015 Olá boa tarde, como eu crio um alert de acordo com o texto digitado no <textarea> ex: <textarea id="myTextarea" placeholder="Digite seu nome"> </textarea> <button type="button" onclick="myFunction()">Try it</button></p> <p id="demo"></p> <script> function myFunction() { var x = document.getElementById("myTextarea").value; document.getElementById("demo").innerHTML = x; } if x=Brendo { alert ("Good name!"); else { alert ("Não te conheço!"); } } Qual o problema que esta acontecendo? Quote Link to comment Share on other sites More sharing options...
0 wootzor Posted June 2, 2015 Report Share Posted June 2, 2015 Olá, experimenta assim: function myFunction() { var x = document.getElementById("myTextarea").value; document.getElementById("demo").innerHTML = x; if (x == "Brendo") { alert("Good name!"); } else { alert("Não te conheço!"); } } Quote Link to comment Share on other sites More sharing options...
0 Brendo Posted June 2, 2015 Author Report Share Posted June 2, 2015 <script type='text/javascript'>window.mod_pagespeed_start = Number(new Date());</script> Olá, experimenta assim: function myFunction() { var x = document.getElementById("myTextarea").value; document.getElementById("demo").innerHTML = x; if (x == "Brendo") { alert("Good name!"); } else { alert("Não te conheço!"); } } Vlw wootzor, não sabia que tinha que colocar esses 2 caracter de == Quote Link to comment Share on other sites More sharing options...
Question
Brendo
Olá boa tarde, como eu crio um alert de acordo com o texto digitado no <textarea>
ex:
<button type="button" onclick="myFunction()">Try it</button></p>
Link to comment
Share on other sites
3 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.