Force Numeric Keyboard for Mobile Device
Asked Answered
S

5

10

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?

Signac answered 20/1, 2011 at 20:1 Comment(2)
There isn't a guaranteed way that will work on ALL devices. Do you have a specific issue you're trying to address? or do you just want an easy way for users to enter a number?Vick
No specific issue, I'd just like it to default to the numeric keyboard.Signac
O
18

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">
Ohg answered 1/8, 2013 at 21:51 Comment(0)
C
9

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.

Coe answered 19/1, 2018 at 9:37 Comment(0)
G
5

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

Gahnite answered 21/1, 2011 at 9:51 Comment(2)
This is for WCSS, which I'm not using. This does not work for regular CSS.Signac
you should be able to use it inline style and if phone supports it, it will work. Works on symbian. discussion.forum.nokia.com/forum/…Gahnite
O
1

I know this is an old question but I was searching for the answer and here is the updated version that should work now.

There is an option to additionally add this to your input:

inputmode="numeric"

So it will be like this:

<input inputmode="numeric" type="number"/>
Oca answered 14/3 at 11:59 Comment(0)
A
0

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/

Assassinate answered 5/7, 2013 at 19:11 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.