html簡單的js實現密碼的隱藏與現實.

代碼以下: 

<html>  
    <head>  
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />  
    </head>  
    <body  align="center"  style="padding-top: 210px">   
        <form method="POST" action="" name="forms">  
            <span id=box><input type="password" name="password" ></span>  
            <span id=click><a href="javascript:showps()">顯示密碼</a></span>  
        </form>  
    </body>  
    <script language="JavaScript">   
                function showps(){   
                    if (this.forms.password.type="password") {  
                        document.getElementById("box").innerHTML="<input type=\"text\" name=\"password\"  value="+this.forms.password.value+">";   
                        document.getElementById("click").innerHTML="<a href=\"javascript:hideps()\">隱藏密碼</a>"  
                    }  
                }   
                function hideps(){   
                    if (this.forms.password.type="text") {  
                        document.getElementById("box").innerHTML="<input type=\"password\" name=\"password\"  value="+this.forms.password.value+">";   
                        document.getElementById("click").innerHTML="<a href=\"javascript:showps()\">顯示密碼</a>"  
                    }   
                }   
    </script>
</html> 
相關文章
相關標籤/搜索