Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

120
Visualizações
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 Respostas
Responde à pergunta

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 Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda