2

iPhone's Mobile Safari seems to recognize most new HTML5 input types, in particular the ones detailed here, such that tapping in an input declared like so:

<input type="number" id="myInput" value=""/>

presents the iPhone's numeric keypad.

However, in the Android browser, the usual text keypad is shown when tapping the same input.

Is there a workaround for the Android browser or an alternative attribute that can be set or even a library I can include to have the android browser respect this setting?

2 Answers 2

1

if you specify on the input element the type as "number" it will automatically open with the numeric keypad example

<input type="number" pattern="[0-9]*" name="amount_zip" value="loading.."></input>

the pattern attribute is for iPhone,

you can also get more info on inputs here

1

I just tried <input type="number"> with a Xoom (Honecomb, I think) and it does cause the numeric keypad to open, which is great, but the field only appears to allow positive integers. Hitting the '-' and '.' keys on the keypad have no effect. Adding relevant min / max attributes or setting a proper pattern don't seem to have any effect. In other words, if you want the keyboard to appear and your numeric field only needs to be zero or a positive integer, this will work. Otherwise (floats, negative numbers), you'll have to use text.

(I realize I'm not answering the question here, I would like to have left this as a comment for the previous answer, but can't figure out how)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.