天天看點

[轉載]Js小技巧||給input type=“password”的輸入框賦預設值

     直接給 input type="password"的輸入框指派不行,由于安全因素,不允許對密碼框賦預設值,隻能通過鍵盤的方式輸入值。而又要在密碼框顯示*密碼,換個思路使用簡單的js腳本即可實作這個效果。

[轉載]Js小技巧||給input type=“password”的輸入框賦預設值

<input type="password" id="txtPass" style="display:none;" runat="Server"/><input type="text" runat="server" id="txtValue" value="******" onclick="RZJ_SetPwd()"/>

<br /><input type="password" id="txtOkPass" style="display:none;" runat="Server" />      
<script type="text/javascript">

    function RZJ_SetPwd()

    {

      var txt1=document.getElementById("txtValue");

      var txt2=document.getElementById("txtPass");

      var txt3=document.getElementById("txtOkPass");

      txt1.value="";

      txt1.style.display="none";

      txt2.style.display="";

      txt3.style.display="";

      txt2.focus();

    }

    </script>