问题1:样式的改变;
问题2:IE内核对type属性设置为只读,无法用js更改
所以:使用CSS样式对input框进行更换处理
<input id="pwd" name="pwd" type="password" style="display:none;" class="int" οnblur="sbOnblur()"/>
<input id="tx" name="tx" type="text" value="密码:" class="int" οnfοcus="sbOnfocus()"/>
function sbOnfocus(){
var tx = document.getElementById("tx");
var pwd = document.getElementById("pwd");
if(tx.value=="密码:"){
tx.value="";
tx.style.display = "none";
pwd.style.display = "";
pwd.value = "";
pwd.focus();
}
}
function sbOnblur(){
var tx = document.getElementById("tx");
var pwd = document.getElementById("pwd");
if(pwd.value==""){
pwd.style.display = "none";
tx.style.display = "";
tx.value = "密码:";
}
}
密码框显示默认值问题处理
最新推荐文章于 2024-01-23 18:07:54 发布