0
votes

I have a big form with many controls. I am using .net regular validator to validate. The submit button is at the bottom. I'd like to display a custom error message when using click on the submit and there are validation errors. How can I do that?

2
custom error for each validator? or just a custom validation summary? - Mo Valipour

2 Answers

0
votes

Use the ErrorMessage property of each validator and the ValidationSummary Control to display all the messages on submit.

0
votes

I think what you are looking for is the Custom Validator How to: Validate with a Custom Function for ASP.NET Server Controls

Here is how it can be implemented...

<asp:CustomValidator ID="CustomValidator1" runat="server" ErrorMessage="invalid text"></asp:CustomValidator>

protected void CustomValidator1_ServerValidate(object source, ServerValidateEventArgs args)
{
    if (Condition == true)
    {
        args.IsValid = true;
    }
    else
    {
        args.IsValid = false;
    }
}