Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

122
Vistas
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 Respuestas
Responde la pregunta

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 Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda