日期:2014-05-17 浏览次数:20876 次
<html> <head> <title>测试密码显示</title> <script> function getPassword(){ var passwordObj=document.getElementById("password"); alert("密码是:"+passwordObj.value); } </script> </head> <body> 密码:<input type="password" value="" name="password" id="password"/> <br/> <input type="button" value="获取密码" onClick="getPassword();"/> </body> </html>
------解决方案--------------------
<script type="text/javascript"> function ps() { if (this.forms.password.type="password") box.innerHTML='<input type="html" name="password" size="20" value="'+this.forms.password.value+'">'; click.innerHTML='<a href="javascript:txt()">隐藏密码</a>' } function txt() { if (this.forms.password.type="text") box.innerHTML='<input type="password" name="password" size="20" value="'+this.forms.password.value+'">'; click.innerHTML='<a href="javascript:ps()">显示密码</a>' } </script> <form method="post" action="" name="forms"> <span id="box"><input type="password" name="password" size="20" value="sina.com"></span> <span id="click"><a href="javascript:ps()">显示密码</a></span> </form>