Force Numeric Keyboard for Mobile Device

杀马特。学长 韩版系。学妹 提交于 2019-12-09 16:02:42

问题


This is not a "mobile" website. It is regular HTML/CSS. Is there a way I can force mobile devices to popup with the numeric keyboard when they focus on my textboxes?


回答1:


We've had the best luck with using a combination of type="number" and pattern="\d*". We've seen success on iOS and Android devices, although I don't have a list of OS versions to share here.

<input type="number" pattern="\d*" name="year">



回答2:


Its called "-wap-input-format". You can use it in your css or in style element such as

<input type="text" style="-wap-input-format: 'N'"/>

See http://www.developershome.com/wap/wcss/wcss_tutorial.asp?page=inputExtension2

Edit: I didn't realize you wanted to pop-up numeric keyboard. I'm not sure if it is possible




回答3:


Just updating this post based on new tech..

<input type="number"/>

Works on most OS's aside from iOS.

So a newer version was introduced where you could simply use:

<input type="tel"/>

This forces a numbered keypad on any mobile device these days.

You can reference here for more info on this exact topic.




回答4:


HTML5 has a new input type "number" that tells mobile devices to bring up the numeric keypad:

<input type="number"/>

Read about it (and the other new input types) here: http://html5doctor.com/html5-forms-input-types/



来源:https://stackoverflow.com/questions/4751941/force-numeric-keyboard-for-mobile-device

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!