Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

asp:RangeValidator not working

Posted on 2011-02-28
3
Medium Priority
?
1,228 Views
Last Modified: 2012-05-11
I'm having trouble with the following asp:RangeValidator control that if I enter a number where the first two or three digits are in between the range it ignores the last digits and still validates.

the range is 1801 - 2201 but all of these numbers still validate:
19, 20, 21, 212, 202, 190, etc.

The test page is here: http://www.glowfishtw.com/stlukes/alumni.aspx
and the code:

<asp:TextBox ID="txtClass" Width="80px" runat="server"></asp:TextBox>
<asp:RangeValidator ID="RangeValidator1" runat="server" ErrorMessage="Enter a valid year." ControlToValidate="txtClass" MaximumValue="2201" MinimumValue="1801" SetFocusOnError="True"></asp:RangeValidator>

How do I get it to only validate numbers between 1801 and 2201?

Thanks
0
Comment
Question by:elliottbenzle
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
3 Comments
 
LVL 44

Accepted Solution

by:
Arthur_Wood earned 2000 total points
ID: 35003893
Your problem probably is because the Maximum and Minimum values are STRINGS (by default) ("2201" and "1801")  and not Numbers.

make this change:

<asp:RangeValidator ID="RangeValidator1" runat="server" ErrorMessage="Enter a valid year." ControlToValidate="txtClass" MaximumValue="2201" MinimumValue="1801" SetFocusOnError="True" Type="Integer" ></asp:RangeValidator>

AW
0
 
LVL 13

Expert Comment

by:devlab2012
ID: 35004585
As @Arthur_Wood mentioned, you need to add Type="Integer". Also, add a RequiredFieldValidator also, otherwise the blank values will be accepted.
0
 
LVL 4

Author Closing Comment

by:elliottbenzle
ID: 35017910
Thanks
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

User art_snob (http://www.experts-exchange.com/M_6114203.html) encountered strange behavior of Android Web browser on his Mobile Web site. It took a while to find the true cause. It happens so, that the Android Web browser (at least up to OS ver. 2.…
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
In this brief tutorial Pawel from AdRem Software explains how you can quickly find out which services are running on your network, or what are the IP addresses of servers responsible for each service. Software used is freeware NetCrunch Tools (https…
In this video, Percona Solutions Engineer Barrett Chambers discusses some of the basic syntax differences between MySQL and MongoDB. To learn more check out our webinar on MongoDB administration for MySQL DBA: https://www.percona.com/resources/we…

661 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question