• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 758
  • Last Modified:

CompareValidator Control

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))
      

<asp:comparevalidator
                  id="cvListingMLS"
                  runat="server"
                  Name="cvListingMLS"
                  ControlToValidate="txtListingMLS"
                  ErrorMessage="Listing MLS must be a number."
                  display="Dynamic"
                  Operator="DataTypeCheck"
                  Type=Integer>*</asp:comparevalidator>
            (Optional)<br>
            <strong>MLS Number:</strong> (max. 5 characters)<br>
            <asp:TextBox ID="txtListingMLS" Runat="server" MaxLength="6"/>

thanks all.
0
vbnewbie01
Asked:
vbnewbie01
1 Solution
 
ayha1999Commented:
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.

ayha
0
 
vbnewbie01Author Commented:
nice one.

thanks.
0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now