1

currently I have a strange problem with RangeValidator.

I have a TextBox declared like this :

<asp:TextBox ID="textBox1" runat="server" type="number"></asp:TextBox>

and a RangeValidator declared like this :

<asp:RangeValidator runat="server"
    ID="rangeValidator1"
    ErrorMessage="Insert between 1-10000"
    ControlToValidate="textBox1"
    MaximumValue="10000"
    MinimumValue="1">

for some reason it only valid when I entered these numbers :

1
10
100
1000
10000

the rest numbers between 1-10000 (ex.: 2-9, 11-99, etc.) simply cause the validator to fail.

why is this happen?

1 Answer 1

4

in order to validator to work with a range of numbers, the Type should be declared as Integer.

this is something I miss.

<asp:RangeValidator runat="server"
    ID="rangeValidator1"
    ErrorMessage="Insert between 1-10000"
    ControlToValidate="textBox1"
    MaximumValue="10000"
    MinimumValue="1"
    Type="Integer">
Sign up to request clarification or add additional context in comments.

3 Comments

You should mark this as answer if it's the answer you were looking for
I will, but SO says that I should wait for 2 days to accept my own answer
Okay then you can wait 2 days

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.