Validator - Shows one error at a time

Is there an easy way to do this?

I have 2 TextBox, for input by email, with regular expression and validator comparison. If the user enters an invalid email address and another email address in the second text box, two error messages are displayed. But I want to display only one error message at a time.

+4
source share
3 answers

In this case, you can try to create your own validator for performing regular expressions, and only perform a compliance check if the record passed the regular expressions (or vice versa, but you want to do it). There may be a simpler solution, but this is the best way I can think of.

+2
source

Perhaps using ValidationSummary control can help you solve your problem in a different way. Well, this will not result in only one error message, but it will place them where you want on your page. Just set the text property for your validation controls to * replace the validationsummary control. Hope this helps.

+2
source

Good question, but could not find a solution to this question. But I would not recommend it. It is always best to show all error messages for required fields. Think of a form with a lot of input fields, and I would not know the error until I scroll down and press the submit button.

What will you achieve by limiting the number of error messages displayed?

0
source

All Articles