c#的textbox文本框怎样做到和input(text)输入框一样能出现失去焦点时文本框显示灰色文字的提示?input(text)文本输入框
<form action="" method="post" name="form">
<input type="text" style="color:#999" name="name" value="这是提示文字" onfocus="this.style.color='#000'; if(this.value=='这是提示文字') { this.value='' }" onblur="if(this.value=='') { this.value='这是提示文字';this.style.color='#999' }"/>
</form>下面的textbox文本框:
<td style="width: 569px" colspan="3">
<asp:TextBox ID="TextBox1" runat="server" Style="z-index: 100; left: 328px; position: static;
top: 138px" Width="156px" MaxLength="20" ></asp:TextBox>
</td>
该文本框怎样修改?
<form action="" method="post" name="form">
<input type="text" style="color:#999" name="name" value="这是提示文字" onfocus="this.style.color='#000'; if(this.value=='这是提示文字') { this.value='' }" onblur="if(this.value=='') { this.value='这是提示文字';this.style.color='#999' }"/>
</form>下面的textbox文本框:
<td style="width: 569px" colspan="3">
<asp:TextBox ID="TextBox1" runat="server" Style="z-index: 100; left: 328px; position: static;
top: 138px" Width="156px" MaxLength="20" ></asp:TextBox>
</td>
该文本框怎样修改?
protected void TextBox1_TextChanged(object sender, EventArgs e)
{
TextBox1.Style.Add("color", "red");
}textBox的Autopostback设为true;
protected void TextBox1_TextChanged(object sender, EventArgs e)
{
TextBox1.Style.Add("color", "gray");
}textBox的Autopostback设为true;
protected void TextBox1_TextChanged(object sender, EventArgs e)
{
TextBox1.Style.Add("color", "gray");
}
TextBox1的autopostback属性设为true;
String.prototype.Trim = function()//去掉空格
{
return this.replace(/(^\s*)|(\s*$)/g,"");
}
function onChangeValue()
{
var obj = document.getElementById("txtSchoolName");
if(obj.value.Trim()=="请输入学校名称")
{
obj.value="";
obj.style.color="Black";
}
} function offChangeValue()
{
var obj = document.getElementById("txtSchoolName");
if(obj.value.Trim()=="")
{
obj.value="请输入学校名称";
obj.style.color="Gray";
}
}
</script>
<asp:TextBox ID="txtSchoolName" ForeColor="gray" onclick="onChangeValue()" onblur="offChangeValue()" runat="server">请输入学校名称</asp:TextBox><asp:Button ID="Button1"
runat="server" Text="查询" OnClick="Button1_Click" />
TextBox1.Attributes.Add("onblur","A()");
function A()
{}