页面载入后让TextBox中显示文字(提示性的字),但是光标移到上面的时候字没了,怎么做

来源:百度知道 编辑:UC知道 时间:2024/06/11 16:30:54

这个有个专门的术语叫做水印,wartermark,
自己做的话需要比较好的javascript水平,而且还要包装
成控件,难度很大。ajax tool kit有现成的控件,拿来
用就行。

<asp:TextBox ID="TextBox1" onfocus="this.value=''" runat="server" Text="提示文字"></asp:TextBox> 这是当光标定位于输入框里面的时候 提示文字消失

<asp:TextBox ID="TextBox1" onmouseover="this.value=''" runat="server" Text="提示文字"></asp:TextBox> 这是当光标移动到输入框上面时 提示文字消失

<script>
function remove(tid)
{
document.getElementById(tid).value = '';
}
</script>
<input id='tid' type='text' onclick='remove(this.id)' value='提示文字' />
光标移走又出现就自己做了,简单得很。

textbox里面加个label
里面写上提示字;
设置事件,
click时label的Visibl属性为false不就可以了..