日期:2014-05-16  浏览次数:20353 次

如何获得input中password的密码输入的字符串的个数?
  如:
<input type="password"  placeholder="密码">
随着键盘输入的改变,密码的个数如何获取呢求指教。。。

------解决方案--------------------
接分的
------解决方案--------------------
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>无标题文档</title>
<script type="text/javascript">
function init(){
var input=document.getElementById("test");
input.onkeyup=function(){
document.getElementById("show").innerHTML=this.value.length;
}
}
window.onload=init;
</script>
</head>

<body>
<input type="password"  placeholder="密码" id="test">
<div id="show"></div>
</body>
</html>


类似这样试试
------解决方案--------------------
document.getElementById("表单id").value.length;
这样就可以获取到了
------解决方案--------------------
length
------解决方案--------------------
<input onkeyup="document.title=this.value.length"

我还以为你已经解决了呢
------解决方案--------------------
下次注意哦