views:

68

answers:

1

I have a textbox that I want the user to enter an integer in.

1) I have created a required field validator, to ensure it is not left blank. 2) A compare validator, to ensure the value entered is an integer using datatypecheck. 3) A range validator to limit the range of the entered integer.

If a letter is entered, instead of an integer, errors from both 2) and 3) are displayed.

Is there a way to only show the error from 2) if a letter is entered and 3) if the integer is out of range - rather than both?

+1  A: 

Why not using only the RangeValidator which checks for integers too?

<asp:RangeValidator id="Range1"
           ControlToValidate="TextBox1"
           MinimumValue="1"
           MaximumValue="10"
           Type="Integer"
           EnableClientScript="false"
           Text="The value must be from 1 to 10!"
           runat="server"/>
Tim Schmelter
didn't know you could get away with only 1 - thanks!
Jonno