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

190
Visualizações
Input Type Number Validation in JavaScript

Form Validation in JavaScript isn't giving me my expected result.

I have a form and event handler. I don't want the user to be able to type in numbers less than 1 or greater than 100. Currently, the min and max in my html code only limits the numbers while scrolling up or down, but they can still type in invalid numbers and not get any warning.

How can I prevent them from typing in numbers less than 1 or greater than 100. I don't have a submit button, and the examples I have seen online are most effective with a submit button. How can I work around this?

const figure = document.getElementById("figure");
figure.addEventListener("change", (event) => (default_figure = event.target.value));
<div class="col-md-12">
  <input type="number" id="figure" class="form-control " placeholder="Assign Class 
       Limit" min="1" max="100" />
</div>

about 4 years ago · Juan Pablo Isaza
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