To be more specific, you need to set the ValidateEmptyMessage property for CustomValdiator to true, otherwise it will not check emprty input fields. Example:
<script type="text/javascript"> function clientValidate(sender, args){ if (args.Value.length == 0) { args.IsValid = false; } } </script> <asp:CustomValidator runat="server" ID="CustomValidator" ControlToValidate="TextBox1" ClientValidationFunction="clientValidate" ValidateEmptyText="true" Text="Error!"> </asp:CustomValidator>
But, as you can see, this is by no means shorter than your previous code, so if it depends on me, in this case there is no point in the user validator. Regarding the original question, unfortunately, there is no way to make RegExpressValidator by default check for empty input fields.
source share