I have a mobile website and it has some HTML input
elements in it, like this:
<input type="text" name="txtAccessoryCost" size="6" />
I have embedded the site into a WebView
for possible Android 2.1 consumption, so that it will also be an Android application.
Is it possible to get the keyboard with numbers instead of the default one with letters when this HTML input
element is focused?
Or, is it possible to set it for the whole application (maybe something in the Manifest file), if it is not feasible for an HTML element?
InputMethodManager imm = (InputMethodManager) getSystemService(Context. INPUT_METHOD_SERVICE); imm. toggleSoftInput(InputMethodManager. SHOW_FORCED,0);
To enable the number row, go to the keyboard Settings and tap on Typing. Under Typing, tap on Keys and enable Number row. Alternatively, enable the number row right from the shortcut settings available by tapping on Settings. The app also lets you customize the location of number pad in the symbols layout screen.
In testing on Android (both Chrome and the older Android Browser), Firefox for Android, and Windows Phone, the only way to trigger a big button keyboard is to ignore the W3C specification and use type="number" .
<input type="number" /> <input type="tel" />
Both of these present the numeric keypad when the input gains focus.
<input type="search" />
shows a normal keyboard with an extra search button
Everything else seems to bring up the standard keyboard.
IMPORTANT NOTE
I am posting this as an answer, not a comment, as it is rather important info and it will attract more attention in this format.
As other fellows pointed, you can force a device to show you a numeric keyboard with type="number"
/ type="tel"
, but I must emphasize that you have to be extremely cautious with this.
If someone expects a number beginning with zeros, such as 000222
, then she is likely to have trouble, as some browsers (desktop Chrome, for instance) will send to the server 222
, which is not what she wants.
About type="tel"
I can't say anything similar but personally I do not use it, as its behavior on different telephones can vary. I have confined myself to the simple pattern="[0-9]*"
which do not work in Android
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With