Why won't my custom validator fire?
I have an ASP.NET web app. I am basically tryign to say a user has to enter eitehr the company name or the owner's name. I have my web page, and on the web page is a user control 开发者_如何转开发with those text fields and a custom control. Here is the custom control and validation summary...
<asp:ValidationSummary ID="ValidationSummary1" runat="server"
CssClass="failureNotification" ValidationGroup="OwnerInfo" />
<asp:CustomValidator ID="CustomValidator1" runat="server"
ClientValidationFunction="CheckOwner" ControlToValidate="txtCompany"
ErrorMessage="Company Name or Owner required" ValidationGroup="OwnerInfo">*</asp:CustomValidator>
Even stripping the actual javascript function down to the bare minimum and trying it in both the control itself and the Headcontent section of the main page, I can't get it to fire. Here is the javascript function...
<script type="text/javascript">
function CheckOwner(source, args) {
args.IsValid = false;
}
</script>
Try this
<script type="text/javascript">
function CheckOwner(source, args) {
return false;
}
</script>
Are you trying to get it to fire for empty text? Is so you need to set the ValidateEmptyText property.
精彩评论