使用 Javascript 在 iPad 中的文本框中输入时如何立即显示数字键盘
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/9287632/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How to show numeric keyboard immediately when entering in a textbox in iPad using Javascript
提问by NevenHuynh
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.
我正在使用 HTML5、CSS3 和 Jquery 为 iPad 开发调查表。根据要求,在邮政编码中立即显示数字键盘而不是字符键盘,然后必须选择按钮切换数字键盘。所以在javascript中,有可能做到吗?如果是,怎么做?请给出一些建议。感谢所有的先进。
回答by EverPresent
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.
我还没有在 iPad 上尝试过查看显示哪个键盘,但如果有办法我确定它是HTML 5 Input Type。这就是新的输入类型应该做的。如果在您设置正确的字体时 iPad 没有按预期运行,我会感到有点惊讶。
Try this code:
<input type="number" name="mynumber"...>
试试这个代码:
<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.
更新:它适用于我的 iPhone (iOS 5.0.1)。它不会像解锁手机时那样拉起“仅数字”键盘,但会像单击普通键盘上的“123”按钮时那样拉起“数字和符号”键盘。
Update:Type changed from 'numeric' to 'number'
更新:类型从“数字”更改为“数字”