There is an input field with the type="number"
loaded with default decimal value. When I want to remove the decimal and submit the form, It gives me validation error (on Chrome) and forces to use decimal. Should I use any special attribute or this is a bug? Besides I don’t want to use step="1"
because sometimes I may need decimals.
<form action="?">
<input type="number" value="123.2423">
<input type="submit" value="submit">
</form>
2
Answers
From MDN web docs –
The number inputs has
step
size 1 by default. If you want to allow to have a value that requires decimals, you’ll need to reflect this in thestep
value (e.g. step="0.0001" to allow decimals to four decimal places).It is not a bug because whenever you use type="number" browser usually expect number input it can be decimal value.
Here how it is to be done
Enter a number:
Submit