CompareValidator Control

Posted on 2005-03-27
Medium Priority
Last Modified: 2008-03-10
does anyone have any suggestions on how i can have the CompareValidator Control check for an integer value and also accept an empty textbox?

the two seem to conflict and, if the textbox is left empty, i get an error message saying the value is an incorrect format (because it's trying to associate an empty string to an integer).

dim intListingMLS as integer = trim(cInt(txtListingMLS.text))

                  ErrorMessage="Listing MLS must be a number."
            <strong>MLS Number:</strong> (max. 5 characters)<br>
            <asp:TextBox ID="txtListingMLS" Runat="server" MaxLength="6"/>

thanks all.
Question by:vbnewbie01
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

Accepted Solution

ayha1999 earned 400 total points
ID: 13644498
Hi  vbnewbie01,

Use RangeValidator instead of compareValidator this will accept empty too but when u enter something it check for integer.

<asp:rangevalidator id="ValMLS" runat="server" ErrorMessage="Your message here." ControlToValidate="txtListingMLS" MinimumValue="1" MaximumValue="999" Type="Integer">*</asp:rangevalidator>

hope this helps.


Author Comment

ID: 13649402
nice one.


Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

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 …
The article shows the basic steps of integrating an HTML theme template into an ASP.NET MVC project
Add bar graphs to Access queries using Unicode block characters. Graphs appear on every record in the color you want. Give life to numbers. Hopes this gives you ideas on visualizing your data in new ways ~ Create a calculated field in a query: …
How to fix incompatible JVM issue while installing Eclipse While installing Eclipse in windows, got one error like above and unable to proceed with the installation. This video describes how to successfully install Eclipse. How to solve incompa…

762 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