如何使用 Javascript 在 iPad 中的文本框中输入时立即显示数字键盘
我正在使用 HTML5、CSS3 和 HTML5 为 iPad 开发一个调查表。 jQuery。根据要求,在邮政编码中立即显示数字键盘而不是字符键盘,然后必须选择按钮来切换数字键盘。那么在javascript中,可以做到吗?如果是的话,该怎么办?请给一些建议。提前感谢大家。
i'm developing a survey form for iPad using HTML5, CSS3 & Jquery. At requirement, in Postal Code show immediately numeric keyboard instead of characters keyboard then have to choose button to switch number keyboard. So in javascript, is it possible to do it ? if it is, how to do it ? please give some suggestion. Thanks all in advanced.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我还没有在 iPad 上尝试过查看显示哪个键盘,但如果有办法的话,我确信它会是 HTML 5 输入类型。这就是新输入类型应该做的事情。当你设置了正确的类型后,如果 iPad 没有按预期运行,我会感到有点惊讶。
试试这个代码:
更新: 它可以在我的 iPhone (iOS 5.0.1) 上运行。它不会像解锁手机时那样拉出“仅数字”键盘,但会拉出“数字和符号”键盘,就像单击普通键盘上的“123”按钮时一样。
更新:类型从“数字”更改为“数字”
I haven't tried it on my iPad to see which keyboard is displayed but if there is a way I'm sure it would be the HTML 5 Input Type. This is what the new input type is supposed to do. I would be mildly surprised if the iPad didn't behave as expected when you have the correct type set.
Try this code:
<input type="number" name="mynumber"...>
Update: It does work on my iPhone (iOS 5.0.1). It doesn't pull up the "numeric only" keyboard like you get when you are unlocking the phone, but it does pull up the "numbers and symbols" keyboard like you get when you click the "123" button on the normal keyboard.
Update: Type changed from 'numeric' to 'number'
嘿,您可以在输入中添加一个属性作为 inputmode="numeric"
示例如下:
Hey you can add a attribute in your input as inputmode="numeric"
Example bellow: