【问题标题】:Force Number Keyboard on Text Input在文本输入上强制使用数字键盘
【发布时间】:2014-11-07 03:33:45
【问题描述】:

我有一个<input type="text"> 元素,我决定使用它来代替type="number",这样我就可以用逗号格式化货币,并且我想为我的移动用户使用数字键盘。 existing solutions I have found 需要 pattern="[0-9]*",但我也需要验证模式。

Codepen here.

如何在不更改输入的patterntype 的情况下使用数字键盘?

【问题讨论】:

  • 您不能强制使用数字键盘,如果您想使用input type=text,成功建议的可能性很小。我很确定这个问题之前在 SO 上被问过。

标签: html regex forms


【解决方案1】:

虽然它还不能在移动浏览器上运行(键盘仍然是文本),we may be able to use the inputmode attribute to set the keyboards on text elements

I have done up a codepen to test this(不适用于 Android 上的最新 chrome)。也许我们会在不久的将来看到这一点。

【讨论】:

    猜你喜欢
    • 2018-07-29
    • 2014-05-07
    • 1970-01-01
    • 2020-07-02
    • 2016-10-18
    • 2019-03-13
    • 2013-05-03
    • 2018-08-17
    • 1970-01-01
    相关资源
    最近更新 更多