最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

jquery - How to show numeric keyboard immediately when entering in a textbox in iPad using Javascript - Stack Overflow

programmeradmin1浏览0评论

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.

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.

Share Improve this question asked Feb 15, 2012 at 3:51 NevenHuynhNevenHuynh 6,8095 gold badges23 silver badges26 bronze badges 2
  • That's the HTML 5 <input type='number'> – Michael Berkowski Commented Feb 15, 2012 at 3:54
  • i have tried it but when run survey in safari on iOS 5.0.1, the keyboard did not appear and can not focus or enter in the input with type='number' attribute – NevenHuynh Commented Feb 15, 2012 at 7:33
Add a ment  | 

2 Answers 2

Reset to default 1

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'

Hey you can add a attribute in your input as inputmode="numeric" Example bellow:

$("input").attr("inputmode", "numeric");

与本文相关的文章

发布评论

评论列表(0)

  1. 暂无评论