开发者

HTML5 inputs on the Android browser

开发者 https://www.devze.com 2023-03-02 18:15 出处:网络
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:

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?


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


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)

0

精彩评论

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