有没有办法有一个蒙面数字输入栏?没有办法、有一个、数字

2023-09-12 07:25:36 作者:欢颜

我建立在Android的HTML5应用程序,并针对这种特定情况下,我们有一个输入字段是信用卡的安全code,我们要强制输入字段只有数字小和屏蔽。

I am creating an HTML5 application on an Android and for this specific scenario, we have an input field that is for a credit card's security code and we want to force the input field to be numberic only and masked.

我有没有运气搜索这种特殊情况下,并从一切我可以告诉从研究/想出来为自己的是,这不能完全通过HTML5(做是因为号码和密码都选择类型,只一种类型的可以使用)。我失去了一些东西,有一种方法,同时具有输入通过HTML5或屏蔽有另一种方式来强制键盘输入型或屏蔽输入,通过CSS或JavaScript?

I have had no luck searching for this specific case and from everything I can tell from researching/trying it out for myself is that this can't be done purely through HTML5 (since number and password are both options for type and only one type can be used). Am I missing something and there is a way to pop-up the numeric keyboard while having the input be masked through HTML5 or is there another way to force the keyboard input type or masking the input through CSS or JavaScript?

感谢您的帮助!

推荐答案

如果它是基于WebKit的浏览器只工作需要,和CSS是允许在纯粹通过HTML5,你可以尝试:

If it's only required to work in WebKit based browsers, and CSS is allowed in 'purely through HTML5', you could try:

input[type=number] {
    -webkit-text-security: disc;
}

我不知道是否有任何目前相当于其他浏览器,在未来这可能是控制通过的 外观 CSS属性 。的CSS3版本外观已被删除的规范,所以它看起来像你必须等待文本安全标准化为一个跨浏览器的解决方案。

I'm not sure if there's currently any equivalent for other browsers, in the future this may be controllable through the appearance CSS property. The CSS3 version of appearance has been dropped from the spec, so it looks like you'll have to wait for the standardization of text-security for a cross browser solution.