【问题标题】:How to force mobile browsers to pull out numeric keyboard for input type="text"?如何强制移动浏览器为输入类型=“文本”拉出数字键盘?
【发布时间】:2014-11-12 09:21:23
【问题描述】:

在我的 angularjs 应用程序中,我有两个输入字段,分别是 type="text"pls see the plunkr here

问题是input type="number" 无法使用货币格式。

所以当焦点移动到input type="text"时,是否可以为移动设备调出数字键盘?

请帮忙

【问题讨论】:

    标签: javascript android jquery html angularjs


    【解决方案1】:

    使用“tel”我相信这会解决您的问题。这也将允许您输入字母,但它会打开数字键盘

    <input type="tel">
    

    【讨论】:

    • 很好,这仍然是 5 年后的最佳解决方案。只有在多个浏览器上同时适用于 Android/iOS 的解决方案。
    【解决方案2】:

    给它添加pattern

    <input type="text" pattern="\d*">
    

    【讨论】:

    • 我打算提出同样的建议。但后来我明白了也需要货币符号?或者currency formatting@Irshu 指的是什么?
    【解决方案3】:

    试试下面的。此外,您可以添加“ng-pattern”来管理验证消息等。

    &lt;input type="text" pattern="[0-9]*"&gt;

    【讨论】:

      猜你喜欢
      • 2020-07-02
      • 2018-07-29
      • 2017-07-31
      • 2013-12-10
      • 1970-01-01
      • 2016-10-18
      • 2016-10-05
      • 2014-05-07
      • 1970-01-01
      相关资源
      最近更新 更多