type的password属性的更改~

有时候password也需要一个占位符,可是由于IE浏览器是只读的,没有办法去更改,这个时候又没有办法去做,那怎么办呢。。。只好多写一个input,,显示隐藏

来源网络~

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>密码的type值的修改</title>
</head>
<style type="text/css">

</style>
<body>
<input name="" type="text" value="密码" class="inputText_1" id="tx" style="width:100px;" />
<input name="" type="password" style="display:none;width:100px;" id="pwd" />
<script type="text/javascript">
var tx = document.getElementById("tx");
var pwd = document.getElementById("pwd");
tx.onfocus = function(){
if(this.value != "密码") return;
this.style.display = "none";
pwd.style.display = "";
pwd.value = "";
pwd.focus();
}
pwd.onblur = function(){
if(this.value != "") return;
this.style.display = "none";
tx.style.display = "";
tx.value = "密码";
}
</script>
</body>
</html>

posted @ 2013-06-07 16:42  捐躯赴国难  阅读(369)  评论(0)    收藏  举报