HTML输入号码步骤无需验证 [英] HTML input number step without validation
问题描述
在HTML中,您可以将步骤
属性添加到类型编号的输入中。我想这是因为我喜欢它可以简化用户输入,只需按下上/下键即可。
In HTML you can add the step
attribute to inputs of type number. I wanted this because I liked how it can simplify the input for the user, by only pressing the up/down key.
我发现这个属性的一个附加特性是,它迫使用户停留在这段时间。 HTML通过验证来做到这一点。您可以手动输入任何值,但不会让您提交表单。
我不想要这个!
I found out that an additional feature of this attribute is, that it forces the user to stay in that interval. HTML does this with validation. You can enter any value manually, but it won't let you submit the form. I don't want this!
要解决这个问题,我发现有一个在
属性,这非常有效。但遗憾的是,浏览器支持很差。< form>
标记中使用的novalidate
To work around with this, I found that there is a novalidate
attribute that is used in the <form>
tag, which works great. But sadly, the browser support is poor.
我想我需要删除步骤
属性并写入我自己用JavaScript / jQuery通过触发keydown事件的功能。
I guess I'd need to remove the step
attribute and write the functionality by myself with JavaScript/jQuery by triggering the keydown event on it.
推荐答案
但遗憾的是,浏览器的支持很差。
But sadly, the browser support is poor.
这是不正确的。根据MDN的说法,从版本10开始,IE支持 novalidate
属性,并且从版本10开始还支持 input [type = number]
。这意味着如果浏览器支持数字输入,它很可能也支持 novalidate
属性。
That's not true. According to MDN, IE supports the novalidate
attribute since version 10, and input[type=number]
also since version 10. This means that if a browser supports number inputs, it most likely also supports the novalidate
attribute.
这篇关于HTML输入号码步骤无需验证的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!