当前位置:Gxlcms > JavaScript > JS文本框默认值处理详解

JS文本框默认值处理详解

时间:2021-07-01 10:21:17 帮助过:20人阅读

代码如下:
<script type="text/javascript">
       function txtFocus(el) {
           if (el.defaultValue == el.value) { el.value = ''; el.style.color = '#000'; }
       }

       function txtBlur(el) {
           if (el.value == '') { el.value = el.defaultValue; el.style.color = '#666'; }
       }
    </script>

<asp:TextBox ID="txtBookPerson" runat="server" CssClass="text2" style="color:#666;" onfocus="txtFocus(this)" onblur="txtBlur(this)" value='请输入预定人' ></asp:TextBox>

人气教程排行