html5在移动端输入密码时怎么改键盘样式为数字键盘?
当 <input type="number">时,弹出来的是数字键盘。
怎么样使 <input type="password">时更改键盘也为数字键盘?
html5在移动端输入密码时怎么改键盘样式为数字键盘?
当 <input type="number">时,弹出来的是数字键盘。
怎么样使 <input type="password">时更改键盘也为数字键盘?
添加类名和CSS,修改type="tel",在手机上看会弹出数字键盘。
<!--CSS-->
<style>
input[type="tel" i].password {
-webkit-text-security: disc;
}
</style>
<!--html-->
<input type="tel" class="password" maxlength="6" pattern="[0-9]*" />
<input type="password" pattern="[0-9]*" onkeyup="this.value=this.value.replace(/\D/g,'');" onafterpaste="this.value=this.value.replace(/\D/g,'');">
10 回答11.2k 阅读
5 回答4.9k 阅读✓ 已解决
4 回答3.1k 阅读✓ 已解决
2 回答2.8k 阅读✓ 已解决
3 回答1.5k 阅读✓ 已解决
3 回答2.3k 阅读✓ 已解决
3 回答2.2k 阅读✓ 已解决
可以设置两个input框,把input设置为绝对定位,上层
设置透明度为0,下层
这样,当你点击input框的时候触发上层input框,即可弹出数字框,然后把数字框value通过js传给下层的input,即为密码,这样模拟实现你说的效果