Rectangle 27 0

html Why can't I enter 500 in a HTML5 number field?


<form>
  <input step="any" type="number" name="width" maxlength="5" placeholder="Width" value="733.95591182365" />
</form>

Sign up for our newsletter and get our top new questions delivered to your inbox (see an example).

I've marked your answer as correct because that would also work, but I solved the problem by rounding the width to an integer before echoing it.

You need to have step="any" as an attribute when working with type="number"

Note
Rectangle 27 0

html Why can't I enter 500 in a HTML5 number field?


733.95591182365
733.95591182365 - 500 = 233.95591182365
  • If the element has a value content attribute, and the result of applying the algorithm to convert a string to a number to the value of the value content attribute is not an error, then return that result and abort these steps.

If you want another step, specify a step attribute. If you don't want any step, use step = "any".

Then, since there is no step attribute, the allowed value step is 11 = 1:

Note