Solved

CompareValidator + RangeValidator not working together

Posted on 2006-11-07
2
440 Views
Last Modified: 2008-06-17
I must be doing something really stupid here but I can't get the following logic to work.  I need the user to enter a numeric (double) figure into the textbox that is between 0 - 250.

So:
   "abc" is not valid
   0 is valid
   53.535 is valid
   250 is valid
   251 is not valid

The page code is as follows:

<asp:TextBox ID="txt_higher" runat="server" />
<asp:CompareValidator ID="cmpval1" runat="server" ControlToValidate="txt_higher" Operator="dataTypeCheck" Type="double" ValidationGroup="vg1" Text="Value in box 1 must be numeric." />
<asp:RangeValidator ID="rngval1" runat="server" ControlToValidate="txt_higher" MaximumValue="250" MinimumValue="0" Text="Value in box 1 must be 0-250." ValidationGroup="vg1" />
<br />
<br />
<asp:Button ID="btn" runat="server" Text="Validate" ValidationGroup="vg1" CausesValidation="true"  />

However if I enter 50 into the box, the page won't validate.  ASP.NET 2.0 seems to think that 50 does not lie between 0-250.  Am I going mad?
0
Comment
Question by:Rouchie
[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
2 Comments
 
LVL 11

Accepted Solution

by:
ethoths earned 500 total points
ID: 17888895
It's doing a text compare. You need to tell it the type...


<asp:RangeValidator type="Double" ID="rngval1" runat="server" ControlToValidate="txt_higher" MaximumValue="250" MinimumValue="0" Text="Value in box 1 must be 0-250." ValidationGroup="vg1" />
0
 
LVL 25

Author Comment

by:Rouchie
ID: 17889212
Ah, so I'm not mad (well, not entirely!).  

Thanks ethoths
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

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

I recently went through the process of creating a Calendar Control of events with the basis of using a database to keep track of the dates that are selectable, one requirement was to have the selected date pop-up in a simple lightbox.  At first this…
Today is the age of broadband.  More and more people are going this route determined to experience the web and it’s multitude of services as quickly and painlessly as possible. Coupled with the move to broadband, people are experiencing the web via …
If you’ve ever visited a web page and noticed a cool font that you really liked the look of, but couldn’t figure out which font it was so that you could use it for your own work, then this video is for you! In this Micro Tutorial, you'll learn yo…
Visualize your data even better in Access queries. Given a date and a value, this lesson shows how to compare that value with the previous value, calculate the difference, and display a circle if the value is the same, an up triangle if it increased…

635 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