强制在iOS8中密码字段使用数字键盘

3

我想强制iOS在我的密码栏中显示数字键盘。我使用以下代码:

<input type="password" pattern="\d*" name="pass"/>

在iOS7中它运行良好,但看起来他们已经改变了密码字段的政策。有什么建议如何在iOS8上强制使用数字键盘输入密码?


当我从UIWebView转到WKWebView时,在混合应用程序中遇到了相同的问题,似乎忽略了pattern属性。 - Andreas Paulsson
2个回答

0
最好的方法是使用CSS。
<input type="text" class="pass" pattern="\d*">
<input type="number" class="pass" pattern="\d*">

这个可以在iOS和Android设备上运行,但是在Windows设备上有问题。

.pass{
    -webkit-text-security: disc;
    -moz-webkit-text-security: disc;
    -moz-text-security: disc;
}

0

由于他们更改了密码策略设置的某些部分,我认为不可能让密码字段打开数字键盘。也许你可以尝试通过给它一个不同的输入类型来绕过数字键盘。

<input type="number"/>

<input type="tel"/>

如果这个方法不起作用,你也可以尝试使用

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

通过将输入类型设置为简单文本并使用 \d* 强制打开数字键盘,就像您在代码中已经尝试过的那样。
也许这个链接对进一步了解会有所帮助: https://developer.apple.com/library/ios/documentation/StringsTextFonts/Conceptual/TextAndWebiPhoneOS/KeyboardManagement/KeyboardManagement.html

可以,但我想把输入显示为****而不是明文。 - DestructiveCreator
你问这个问题有一段时间了,除了这个解决方法,你找到其他解决方案了吗?我也遇到了同样的问题:( - Lave Loos

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接