Jump to content
Fórum Script Brasil
  • 0

Criar alert


Brendo
 Share

Question

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 by Brendo
Link to comment
Share on other sites

3 answers to this question

Recommended Posts

  • 0

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?
Link to comment
Share on other sites

  • 0

<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 ==

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Answer this question...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

  • Forum Statistics

    • Total Topics
      149.8k
    • Total Posts
      646.6k
×
×
  • Create New...