我正在尝试创建一个输入字段来输入 pin。在移动设备中,我希望 pin 不以纯文本形式显示,如密码输入字段。我在 stackoverflow 中为此找到了这个建议,但到目前为止都没有用
<input type="password" name="PIN" pattern="[0-9]*" inputmode="numeric" style="-webkit-text-security: disc;" required>
有什么办法可以实现吗?
最佳答案
你可以使用 CSS
#password{
-webkit-text-security: disc;
-moz-text-security:circle;
text-security:circle;
}
input[type=number]::-webkit-inner-spin-button,
input[type=number]::-webkit-outer-spin-button {
-webkit-appearance: none;
margin: 0;
}
<input type="number" id="password" pattern="[0-9]*" >
您可以通过多种方式做到这一点,最简单的方法是使用 CSS 希望对你有帮助:)
关于javascript - 如何让输入框同时输入数字和密码?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56693016/