对于某些密码,想要在手机上调出数字键盘,同时要隐藏文字。可结合type=tel和 text-security属性达到目的。
input{
-webkit-text-security:disc;
text-security:disc; /*使用指定形状代替文字显示 circle圆圈 disc 圆形 square 正方形*/
}
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>输入密码时,调出手机的数字键盘</title>
<style>
input{
-webkit-text-security:disc;
text-security:disc; /*使用指定形状代替文字显示 circle圆圈 disc 圆形 square 正方形*/
}
</style>
</head>
<body>
<input type="tel" id="pass" />
<script>
window.onload = init;
function init(){
var x = document.getElementById("pass");
var style = window.getComputedStyle(x);
if(style.webkitTextSecurity){
//do nothing
}else{
x.setAttribute("type","password");
}
}
</script>
</body>
</html>
原文:http://www.cnblogs.com/lydialee/p/5671317.html