Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6245153
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T12:27:20+00:00 2026-05-24T12:27:20+00:00

I want to set a Range Validator on a text box to prevent someone

  • 0

I want to set a Range Validator on a text box to prevent someone from ordering more of a product than is available. I have the amount available stored in a database and I databound the maximum value property of the Ranged Validator to the field in the database.

<asp:RangeValidator ID="RangeValidator1" runat="server" 
                    ControlToValidate="tbQuantity" Display="Dynamic" ErrorMessage = "Can't Order More Than Quantity." 
                    ForeColor="Red" MaximumValue='<%# Eval("Quantity") %>' MinimumValue="0"></asp:RangeValidator>

However when I debug the program I get some unexpected results.

The quantity is 17.
and 1 does not trigger the error message, but 2-9 does and 10-17 doesn’t trigger it but 18 and up do. I’m guessing this has something to do with the fact that it is comparing strings but I’m not sure how to change it to comparing numbers.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-24T12:27:20+00:00Added an answer on May 24, 2026 at 12:27 pm

    The default range validator type is string, change the Type property to Integer

    <asp:RangeValidator 
        ID="RangeValidator1" runat="server" 
        ControlToValidate="tbQuantity"
        Display="Dynamic"
        ErrorMessage="Can't Order More Than Quantity." 
        ForeColor="Red"
        MaximumValue='<%# Eval("Quantity") %>'
        MinimumValue="0"
        Type="Integer" /> // <-- add type property of integer
    

    http://msdn.microsoft.com/en-us/library/system.web.ui.webcontrols.basecomparevalidator.type.aspx

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a range named STATE. I want to set data validation in range
I want to set minValue and maxValue of text boxes to define a range
My animation is 100 frames total. I want to set a range of frames.
I have a CFINPUT tag in a CFFORM . I want to set the
I want to perform a set of network tasks on an IP address range.
I have a set of x,y map coordinates that I want plotted on an
So i have this slider with a range. And usually, when I set the
I want to check a range of cells for a certain piece of text.
I want to set bold the charecters within specific range as Bold. How could
I have CATextLayer and want to set background color to part of the string.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.