<asp:TextBox ID="KeyWords" runat="server" Width="200px">

<asp:CustomValidator id="CustomValidator1"   ControlToValidate="KeyWords" ClientValidationFunction="ClientValidate" Display="None"

ValidationGroup="seachers" runat="server"/>

验证脚本:

             <script type="text/javascript">
              function ClientValidate(source,arguments) //这里arguments可获取TextBox值
              {
                 if(arguments.Value == "请输入关键词搜索" || arguments.Value == "")
                 {            
                     alert("请输入关键词");   
                     arguments.IsValid = false;                  
                 }
                 else
                 {
                   arguments.IsValid = true;
                 }

            }
           </script>

posted on 2010-01-18 15:45  sweting  阅读(838)  评论(0编辑  收藏  举报