2

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 Answer 1

2

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"/>
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.