Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

175
Views
How to show a div when the enter key has been pressed in two textareas?

How do you detect that the enter key was pressed in two textareas? I have a way to detect the enter key was pressed in one textarea and need help with detecting the enter key was pressed in two textareas.

This is what I've done so far:

$('#test1').keyup(function(e) {
   if(e.keyCode == 13) {
        $("#GFG_DOWN").text("Enter key pressed inside textarea");
   }
});  
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<textarea id="test1"></textarea>
        <textarea id="test2"></textarea>
        <br>     
          
        <p id = "GFG_DOWN" style = 
            "color:green; font-size: 20px; font-weight: bold;">
        </p>

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

I guess you must handle this with two FlagVariables.

let text1Flag = false;
let text2Flag = false;

function callbackHandler(e, textType) {
   if(e.keyCode == 13) {
        if (textType == 1) {
            text1Flag = true;
        } else {
            text2Flag = true;
        }
        if (text1Flag && text2Flag) {
           $("#GFG_DOWN").text("Enter key pressed inside textarea");
            text1Flag = false;
            text2Flag = false;
        }
   }
}

$("#test1").keyup((ev) => callbackHandler(ev, 1));
$("#test2").keyup((ev) => callbackHandler(ev, 2));
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<textarea id="test1"></textarea>
        <textarea id="test2"></textarea>
        <br>     
          
        <p id = "GFG_DOWN" style = 
            "color:green; font-size: 20px; font-weight: bold;">
        </p>

about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!