Solved

CompareValidator + RangeValidator not working together

Posted on 2006-11-07
2
431 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
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

Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

Join & Write a Comment

Lots of people ask this question on how to extend the “MembershipProvider” to make use of custom authentication like using existing database or make use of some other way of authentication. Many blogs show you how to extend the membership provider c…
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 video demonstrates how to create an example email signature rule for a department in a company using CodeTwo Exchange Rules. The signature will be inserted beneath users' latest emails in conversations and will be displayed in users' Sent Items…
You have products, that come in variants and want to set different prices for them? Watch this micro tutorial that describes how to configure prices for Magento super attributes. Assigning simple products to configurable: We assigned simple products…

743 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

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now