javasript實(shí)現(xiàn)密碼的隱藏與顯示

字號(hào):


    用戶輸入密碼時(shí)都是顯示的星號(hào)了,那么我們希望查看明文要怎么查看呢,下面我們只要使用一段簡(jiǎn)單的js就可以實(shí)現(xiàn)查看密碼框的明文了,有需要的小伙伴可以來(lái)參考下。
    javascript實(shí)現(xiàn)的查看隱藏的密碼框中明文信息的方法,用戶輸入密碼時(shí)顯示星號(hào),如何查看明文信息呢,用js可以實(shí)現(xiàn)查看密碼框的明文。
    在密碼框中輸入密碼,會(huì)以星號(hào)來(lái)顯示,文字內(nèi)容被自動(dòng)隱藏了。
    用戶輸入密碼時(shí)顯示星號(hào),如何查看明文信息呢,用js可以實(shí)現(xiàn)查看密碼框的明文。
    代碼如下:
    <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>效果顯示</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>
    以上所述就是本文的全部?jī)?nèi)容,有需要的小伙伴可以參考下。