直接给 input type="password"的输入框赋值不行,由于安全因素,不允许对密码框赋默认值,只能通过键盘的方式输入值。而又要在密码框显示*密码,换个思路使用简单的js脚本即可实现这个效果。
<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>
本文介绍了一种在密码输入框中预设默认值的方法,通过巧妙利用JS脚本来实现密码框显示星号(*)代替实际密码的效果,解决了直接设置密码框默认值的安全限制问题。
1644

被折叠的 条评论
为什么被折叠?



