javascript - 密码框提示变成 .
本文介绍了javascript - 密码框提示变成 .的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
问 题
密码框里的提示密码两个字变成两个点了,怎么解决
(不要用placeholder,不兼容ie8)
解决了,不过不知道会不会有bug
<!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=utf-8" />
<script src="http://libs.baidu.com/jquery/1.10.2/jquery.min.js">
</script>
<title>无标题文档</title>
<script type="text/javascript">
$(function(){
$("#mima").focusin(function () {
if($("#mima").val()==""||$("#mima").val()=="密码")
{
$(this).val("");
$(this).attr('type','password');
}
});
$("#mima").focusout(function () {
if($("#mima").val()==""||$("#mima").val()=="密码")
{
$(this).val("密码");
$(this).attr('type','text');
}
});
});
</script>
</head>
<body>
<input name="mima" id="mima" style="line-height:270%" type="text" value="密码" />
</body>
</html>
解决方案
<input type="text" value="请输入密码!" onfocus="if(this.value==defaultValue) {this.value='';this.type='password'}" onblur="if(!value) {value=defaultValue; this.type='text';}" style="color:#CCC;" />
这篇关于javascript - 密码框提示变成 .的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文