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

231
Visualizações
Number input min attribute not working with floats

With the below HTML, when I type the value 3 in the input and click on submit, Chrome (at least) shows the following error in a popup:

Please enter a valid value. The two nearest valid values are 2.0001 and 3.0001.

This doesn't make sense. I've set the minimum value to be 0.0001 and I'm entering 3 which is greater than 0.0001.

document.getElementById('form').onsubmit = function(e) {
  e.preventDefault()
}
<form id="form">

  <input placeholder="0.000" 
         id="something" 
         type="number" 
         name="something" 
         min="0.0001" 
         required>
       
  <button type="submit">submit</button>
  
</form>

about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

The default value for the step attribute is 1, and since you've a min applied on your input, there's no integral n such that min + n * step (0.0001 + n * 1) equals 3.

You can change the step to 0.0001 or any.

document.getElementById('form').onsubmit = function(e) {
  e.preventDefault();
  console.log(e.target.elements[0].value);
}
<form id="form" onsubmit="onSubmit">
  <input
    placeholder="0.000"
    id="something"
    type="number"
    name="something"
    min="0.0001"
    step="any"
    required
  >
  <button type="submit">submit</button>
</form>

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