[转载]Js小技巧||给input type=“password”的输入框赋默认值
直接给 input type="password"的输入框赋值不行,由于安全因素,不允许对密码框赋默认值,只能通过键盘的方式输入值。而又要在密码框显示*密码,换个思路使用简单的js脚本即可实现这个效果。
<input type="password" /> <br /><input type="password" />
<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>
直接给 input type="password"的输入框赋值不行,由于安全因素,不允许对密码框赋默认值,只能通过键盘的方式输入值。而又要在密码框显示*密码,换个思路使用简单的js脚本即可实现这个效果。
<input type="password" /> <br /><input type="password" />
<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>