skip to Main Content

I have HTML input which is set to be a numeric input including the up and down carets. To my surprise I am unable to enter any decimal numbers.

<input type="number" />

It does not accept such input and jumps back to a non-decimal number. Is there any way I can keep the input type numeric and still allow decimal numbers?

2

Answers


  1. you can use step attribute to say the number input allow decimal

    <input type="number" min="0" max="10" step="0.1"/>
    Login or Signup to reply.
  2. If you want to allow any number of decimal then use this:

    <input type="number" step="any" />
    

    If you want specific like two decimal places then set like this:

    <input type="number" step="0.01" />
    

    Hope it helps!

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search