Solved

asp:RangeValidator not working

Posted on 2011-02-28
3
1,223 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 500 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

PeopleSoft Has Never Been Easier

PeopleSoft Adoption Made Smooth & Simple!

On-The-Job Training Is made Intuitive & Easy With WalkMe's On-Screen Guidance Tool.  Claim Your Free WalkMe Account Now

Question has a verified solution.

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

Problem Hi all,    While many today have fast Internet connection, there are many still who do not, or are connecting through devices with a slower connect, so light web pages and fast load times are still popular.    If your ASP.NET page …
This article shows how to deploy dynamic backgrounds to computers depending on the aspect ratio of display
In this video, viewers will be given step by step instructions on adjusting mouse, pointer and cursor visibility in Microsoft Windows 10. The video seeks to educate those who are struggling with the new Windows 10 Graphical User Interface. Change Cu…
Sometimes it takes a new vantage point, apart from our everyday security practices, to truly see our Active Directory (AD) vulnerabilities. We get used to implementing the same techniques and checking the same areas for a breach. This pattern can re…

622 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