Sometimes, we want to allow 2 decimal places in number inputs with HTML.
In this article, we’ll look at how to allow 2 decimal places in number inputs with HTML.
How to allow 2 decimal places in number inputs with HTML?
To allow 2 decimal places in number inputs with HTML, we can set the step
attribute.
For instance, we write
<input type="number" step="0.01" class="form-control" />
to set the step
attribute to 0.01 to allow 2 decimal places to be entered into the number input.
Conclusion
To allow 2 decimal places in number inputs with HTML, we can set the step
attribute.