对于下面的 HTML,当我在输入中键入值3并单击时submit,Chrome(至少)会在弹出窗口中显示以下错误:
Please enter a valid value. The two nearest valid values are 2.0001 and 3.0001.
Run Code Online (Sandbox Code Playgroud)
这没有道理。我已将最小值设置为0.0001,并且输入大于0.0001 的3。
Please enter a valid value. The two nearest valid values are 2.0001 and 3.0001.
Run Code Online (Sandbox Code Playgroud)
document.getElementById('form').onsubmit = function(e) {
e.preventDefault()
}Run Code Online (Sandbox Code Playgroud)
step该属性的默认值为1,并且由于您已min对输入应用了 a ,因此不存在( ) 等于 的积分。nmin + n * step0.0001 + n * 13
您可以将步骤更改为0.0001或any。
document.getElementById('form').onsubmit = function(e) {
e.preventDefault();
console.log(e.target.elements[0].value);
}Run Code Online (Sandbox Code Playgroud)
<form id="form" onsubmit="onSubmit">
<input
placeholder="0.000"
id="something"
type="number"
name="something"
min="0.0001"
step="any"
required
>
<button type="submit">submit</button>
</form>Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
164 次 |
| 最近记录: |