ValidateEmptyText in ASP.NET 2.0 CustomValidator

In the previous version of, v1.1, the CustomValidator did NOT run when the control(e.g TextBox) was empty. Possible solutions were to create your own control (something like RequiredCustomValidator : CustomValidator) or the change WebUIValidation.js file so it will actually validate the control even if it’s empty. Now, in the new version, v2.0, you can simply set the ValidateEmptyText to true and you’re done. Nice (and useful) !


Oren Ellenbogen


2 thoughts on “ValidateEmptyText in ASP.NET 2.0 CustomValidator

  1. Hi there, I m not able to fire the ValidateEmptyText even I have set it to true.

    <asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
    <asp:CustomValidator ID="CustomValidator1" runat="server" ControlToValidate="TextBox1" ValidateEmptyText="true" ErrorMessage="CustomValidator"></asp:CustomValidator>
    <asp:Button ID="Button1" runat="server" Text="Button" CausesValidation="true" />

    Any idea? Thank you.

Comments are closed.