验证 html5 中的输入类型编号
我想将输入限制在数字类型字段中,以便输入不能超出 html 中指定的最小-最大范围。
input type = "number" min = "1" max = "5"
有没有一种方法可以在没有文本框的情况下输出数字字段,我宁愿不使用
“input type = range”
,因为滑块不显示当前选择的值
请帮忙。
谢谢。
I want to restrict entry of input onto a field of type number such that input cannot be outside range of min-max specified in the html.
input type = "number" min = "1" max = "5"
Is there a way of outputting the number field without the text box and i would rather not use
"input type = range"
as slider does not show value currently selected
Please help.
Thanks.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
根据您所说的,我建议使用一个简单的输入文本字段,并在通过 JavaScript 提交时检查其值的有效性(如 @Kush 上面提到的)。您还可以在用户键入时检查它,或者将焦点从该字段移开。
Based on what you said, I suggest using a simple input text field and check it's value validity on submission via JavaScript (as @Kush mentions above). You could also check it as the user types, or moves focus away from that field.