显示、隐藏密码的js代码

发布时间:2019-10-20编辑:脚本学堂
js实现的可以显示与隐藏密码的代码,有需要的朋友,可以参考下。

完整代码如下:
 

复制代码 代码示例:
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<meta name="GENERATOR" content="Microsoft FrontPage 4.0">
<meta name="ProgId" content="FrontPage.Editor.Document">
<title>显示、隐藏密码-www.jb200.com</title>
<style>
body,input{font:menu}
</style>
</head>
<body>
<form method="POST" action="addcheck.asp" name="forms">
<span id=box><input type="password" name="password" size="20" value="51windows.com"></span>
<span id=click><a href="javascript:ps()">显示密码</a></span>
<script language="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>
<script>
function help(){
title="显示、隐藏密码"
time="23:17 2013-3-23"
tips="显示、隐藏input中的密码,动态改为input的type值。)"
alert(title+"n("+time+")nn"+tips)}
</script>
</body>
</html>