有没有办法有一个屏蔽数字输入字段?
我正在 Android 上创建一个 HTML5 应用程序,对于这个特定场景,我们有一个用于信用卡安全代码的输入字段,我们希望强制输入字段仅包含数字并被屏蔽。
我没有运气搜索这个特定的案例,从我自己研究/尝试中可以看出,这不能纯粹通过 HTML5 来完成(因为数字和密码都是类型选项,并且只有一种类型可以被使用)。我是否遗漏了一些东西,有一种方法可以在通过 HTML5 屏蔽输入的同时弹出数字键盘,或者是否有另一种方法可以强制键盘输入类型或通过 CSS 或 JavaScript 屏蔽输入?
感谢您的帮助!
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.
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?
Thanks for any help!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
如果只需要在基于WebKit的浏览器中工作,并且“纯粹通过HTML5”允许使用CSS,您可以尝试:
我不确定目前其他浏览器是否有等效的
,将来这可能是可控的通过。 CSS3 版本的外观
CSS 属性appearance
已从规范中删除,因此看来您必须等待text-security
的标准化才能获得跨浏览器解决方案。If it's only required to work in WebKit based browsers, and CSS is allowed in 'purely through HTML5', you could try:
I'm not sure if there's currently any equivalent for other browsers
, in the future this may be controllable through the. The CSS3 version ofappearance
CSS propertyappearance
has been dropped from the spec, so it looks like you'll have to wait for the standardization oftext-security
for a cross browser solution.