If you have a form where you have declare a input type as below:
Now if you enter a floating-point/decimal value like '2.1' and try to process your form then you will get the following error message:
"Please enter a valid value. The two nearest valid values are 2 and 3."
step="any"
to your form. So, your input code should be as follows:
Now, you should be able to enter decimal/floating-point values and process them without any hassle.
<input type="number" name="quantity" min="1" max="5">
Now if you enter a floating-point/decimal value like '2.1' and try to process your form then you will get the following error message:
"Please enter a valid value. The two nearest valid values are 2 and 3."
Click on image to enlarge |
Solution:
To solve this just addstep="any"
to your form. So, your input code should be as follows:
<input type="number" name="quantity" min="1" max="5" step="any">
Now, you should be able to enter decimal/floating-point values and process them without any hassle.