How to force keyboard with numbers in mobile website in Android

前端 未结 7 1562
南旧
南旧 2020-11-28 23:31

I have a mobile website and it has some HTML input elements in it, like this:



        
7条回答
  •  情话喂你
    2020-11-29 00:11

    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

提交回复
热议问题