ASP.NET TextBox 当鼠标点击后清空默认提示文字[转]

前台文本框里添加下面2个事件属性:

OnFocus="javascript:if(this.value=='提示文字') {this.value=''}"

OnBlur="javascript:if(this.value=='') {this.value='提示文字'}"

-----------------------------------例-----------------------------------------

<asp:TextBox ID="txtName" runat="server" Text="请输入用户名"

OnFocus="javascript:if(this.value=='请输入用户名') {this.value=''}"

OnBlur="javascript:if(this.value==''){this.value='请输入用户名'}">

</asp:TextBox>

<asp:TextBox ID="txtPwd" runat="server" Text="请输入密码"

OnFocus="javascript:if(this.value=='请输入密码') {this.value=''}"

OnBlur="javascript:if(this.value==''){this.value='请输入密码'}">

</asp:TextBox>

原博客地址: http://www.cnblogs.com/carekee/articles/2093593.html

posted @ 2016-04-21 09:26  翼龙zyl  阅读(1325)  评论(0编辑  收藏  举报