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

114
Views
HTML text input triggers change event too late

I have a problem with my input, where it calls my change event, only after i click away from the input. I want the event to be called when the user adds some text to my input.

function textChange(ele) {
    let btn = document.getElementById("addThingBtn");
    if (ele.value.length) btn.disabled = false;
    else btn.disabled = true;
}
input {
    height: 35px;
    float: left;
    text-align: center;
}

button {
    width: 120px;
    height: 40px;
    float: left;
    text-align: center;
    margin-left: 5px;
}
<input type="text" id="newThingName" onchange="textChange(this);" placeholder="new thing name">
<button id="addThingBtn" onclick="addThing();" disabled> Add thing </button>

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

0

I was actually looking for the input event, not for the change event.

function textChange(ele) {
    let btn = document.getElementById("addThingBtn");
    if (ele.value.length) btn.disabled = false;
    else btn.disabled = true;
}
input {
    height: 35px;
    float: left;
    text-align: center;
}

button {
    width: 120px;
    height: 40px;
    float: left;
    text-align: center;
    margin-left: 5px;
}
<input type="text" id="newThingName" oninput="textChange(this);" placeholder="new thing name">
<button id="addThingBtn" onclick="addThing();" disabled> Add thing </button>

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!