asp.netvalidation

asp .net multiple validators for one control


I am developing asp.net web site. I have a from on a page and have text boxes. I am using Validators to validate fields. I used two validators to validate my telephone number field. One to check length and other to check All entered value are numbers

My issue is: for a invalid input which does not match above two conditions, bot the error messages are displaying.

I would like to display only 1 error message at a time. Is this possible? Please advice me.


Solution

  • I managed to fix my issue using CSS. I wrote a new CSS class .errorMsg in my style sheet to handle the display style of error messages.

    I assigned that CSS class to each validator. To avoid overlapping of multiple error messages, I assigned background color for the error message <span> tag. (The background-color is same as the form's BbColor).

    So now overlapped messages are not showing; only the topmost error is showing.