Home  >  Article  >  Web Front-end  >  javasript实现密码的隐藏与显示_javascript技巧

javasript实现密码的隐藏与显示_javascript技巧

WBOY
WBOYOriginal
2016-05-16 16:00:131238browse

javascript实现的查看隐藏的密码框中明文信息的方法,用户输入密码时显示星号,如何查看明文信息呢,用js可以实现查看密码框的明文。

在密码框中输入密码,会以星号来显示,文字内容被自动隐藏了。

用户输入密码时显示星号,如何查看明文信息呢,用js可以实现查看密码框的明文。

代码:

<html><head><title>密码的隐藏与显示</title>
</head>
<body bgcolor=#fef4d9><br><br>
<center>密码的隐藏与显示</center><br>
<center>
<table bordercolor=#cc0000 border=5 borderlight="green">
<tbody>
<tr>
<td align=middle><div align="center">效果显示</div></td>
</tr>
<tr>
<td align=middle>
<form name=forms action="" method=post><span id=box>
<input type=password value=523654 name=password></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></td></tr></tbody></table></center>
</body>
</html>

以上所述就是本文的全部内容,有需要的小伙伴可以参考下。

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn