开发者

Can you provide a hint to a mobile device that an HTML input field is numeric-only?

I've been doing some usability testing on a website I'm developing, using an Android phone and an iPod touch. In bo开发者_开发技巧th cases, when entering a numeric field (time, distance in metres, etc) I have to take a manual step to change the keyboard layout to show digits. As the app will only accept numeric values in the textbox, I'd like to save the user the inconvenience and tell the device "switch to the number pad for this input".

Is this possible?


After some browsing, it seems that HTML 5 offers some answers for this, though they're not widely supported.

Specifically, the number type input:

<input type="number"
       min="0"
       max="10"
       step="2"
       value="6">

Here's a demo. Works on Chrome 6.0.472.51 (beta). Have yet to test on Android/iPhone but apparently it works.

Can you provide a hint to a mobile device that an HTML input field is numeric-only?


(source: wearehugh.com)

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜