Jump to content
Fórum Script Brasil
  • 0

onpresskey enter



Bom dia, como eu posso exibir um alerta ao digitar o string especifica e aperta enter?


function Enter(event) {
var x = document.getElementById("myText").value;
if ( (x=="Brendo")+ (event.keyCode==13 )) {
alert ("good name!");
} else {
alert ("Nome não reconhecido!");
<p id="primeira"> Digite seu nome</p>
<textarea onkeypress="Enter(event)" id="myText" placeholder="Digite sua resposta" class="textarea-block textarea-lg textarea-translate" id="text-input" name="text-input" lang="en" tabindex="1" style="overflow: hidden; word-wrap: break-word; resize: none; height: 120px;"></textarea>
<button type="button" onclick="Enter(event)">Try it</button></p>
Link to comment
Share on other sites

0 answers to this question

Recommended Posts

There have been no answers to this question yet

Join the conversation

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

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.


  • Forum Statistics

    • Total Topics
    • Total Posts
  • Create New...