<html> <head> <meta charset="utf-8"> <title>密码明文</title> <script language="JavaScript"> function demo(){ var tp=document.all["passwd"]; //tp.setAttribute("type","text"); //ok1 //tp.type="text"; //ok2 var rd=document.all["rd"]; if(rd.checked){ tp.type="text"; }else{ tp.type="password"; } } </script> </head> <body> <form> <fieldset style="width:300px;margin-left:35%;margin-top:10%;"> <legend >设置为可选明文密码</legend> <table> <tr> <td><label for="rd" onfocus="demo()">是否为明文</label></td> <td><input type="checkbox" id="rd" name="rd" onclick="demo()"/></td> </tr> <tr> <td>用户名:</td> <td><input type="text" id="username"/></td> </tr> <tr> <td>密 码:</td> <td><input type="password" id="passwd" name="passwd"/></td> </tr> </table> </fieldset> </form> </body> </html>
相关文章: