您的位置:首页 > 其它

给input文本框添加灰色提示文字

2014-11-25 10:54 162 查看
<td>
<div align="right">
用户ID:
</div>
</td>
<td>
<div align="left">
  
<input type="text" name="userid" id="userid" value="8位数字前4位为部门编号" onfocus="TextOnFocusShow(this.id);" onblur="TextOnBlurShow(this.id);" style="color:#999999"/>
</div>
</td>


// 文本框清空灰色提示
function TextOnFocusShow(showId)
{
var showIdTextValue = document.getElementById(showId).value;
var showIdTextDeValue = document.getElementById(showId).defaultValue;// text初始设置
if(showIdTextValue == showIdTextDeValue)
{
document.getElementById(showId).value = "";
document.getElementById(showId).style.color='#000';
}
}
// 文本框为空时增加灰色提示
function TextOnBlurShow(showId)
{
var lDateValue = document.getElementById(showId).value;
var lDateDefaultValue = document.getElementById(showId).defaultValue;
if(lDateValue == '')
{
document.getElementById(showId).value = lDateDefaultValue;
document.getElementById(showId).style.color='#999';
}
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: