Why can’t I enter 500 in a HTML5 number field?
我的 HTML5 数字字段不断收到奇怪的意外验证错误。这是我的 HTML 代码:
1
|
<input type="number" name="width" maxlength="5" placeholder="Width" value="733.95591182365" />Width<br />
|
当我输入 500 并提交表单时,我收到错误:”请输入一个有效值。两个最接近的有效值是 499.95591182365 和 500.95591182365。”
我已经解决了这个问题。问题是这个
在使用
时,您需要将
1
2 3 |
<form>
<input step="any" type="number" name="width" maxlength="5" placeholder="Width" value="733.95591182365" /> </form> |
对于数字输入,
The step scale factor is 1. The default step is 1
那么,由于没有
If the attribute is absent, then the allowed value step is the
default step multiplied by the step scale factor.
步长为
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 thevalue content attribute is not an error, then
return that result and abort these steps.
因此,
Constraint validation: When the element has an allowed value step, and the result of applying the algorithm to convert a
string to a number to the string given by the element’s
value is a number, and that number subtracted from the step
base is not an integral multiple of the allowed value step,
the element is suffering from a step mismatch.
由于
如果您想要另一个步骤,请指定一个
原创文章,作者:ItWorker,如若转载,请注明出处:https://blog.ytso.com/tech/269204.html