<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>