您的位置:首页 > 其它

在不同浏览器input密码的提示文字

2014-08-15 18:28 337 查看
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">

<head>

<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />

<title>无标题文档</title>

</head>

<body>

<input name="" type="text" value="密码" id="tx" style="width:100px;" />

<input name="" type="password" style="display:none;width:100px;" id="pwd" />

<input name="" type="text" value="确认密码" id="tx1" style="width:100px;" />

<input name="" type="password" style="display:none;width:100px;" id="pwd1" />

<script type="text/javascript">

var tx = document.getElementById("tx"), 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 = "密码";

}

var tx1 = document.getElementById("tx1"), pwd1 = document.getElementById("pwd1");

tx1.onfocus = function(){

if(this.value != "确认密码") return;

this.style.display = "none";

pwd1.style.display = "";

pwd1.value = "";

pwd1.focus();

}

pwd1.onblur = function(){

if(this.value != "") return;

this.style.display = "none";

tx1.style.display = "";

tx1.value = "确认密码";

}

</script>

</body>

</html>
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: