ASP.NET RangeValidator Control Element

RangeValidator control element

The RangeValidator control checks that the entered value is within a certain range. It has three special properties: MinimumValue, MaximumValue, and Type.

The MinimumValue and MaximumValue properties define the range of valid values and the Type property defines the type of data that will be entered in the input control and checked for validity. The supported values are Currency, Date, Double, Integer and String.

The following example will test if the date entered is between January 1 and December 31, 2012 (here the dates are encoded in a locale-independent format “dd/MM/yyyy”; if the web server uses other regional settings, change the date format):

<asp:TextBox runat="server" Width="200px" ID="DayOff" />
<asp:RangeValidator runat="server" ID="ValidateDayOff2" ControlToValidate="DayOff" 
        MinimumValue="01/01/2012" MaximumValue="31/12/2012" Type="Date" 
        ErrorMessage="The date value is not within the specified range" Display="dynamic" 

The RangeValidator control checks that the input value is within the specified range.

It has three specific properties:

TypeIt defines the data type. The following values are available: Currency, Date, Double, Integer and String.
MinimumValueSpecifies the minimum value of the range.
MaximumValueSpecifies the maximum value of the range.
Leave a Reply

Your email address will not be published. Required fields are marked *

You May Also Like
Read More

Web projects

So far, we’ve only covered how you can create websites without any project files. The advantage of project-free development…