The RangeValidator Server Control makes sure that the entered user value or selection provided is between a specified ranges.It is possible to check ranges within numbers, dates, and characters.

The validation will not fail if the input control is empty. Use the RequiredFieldValidator control to make the field required.

<asp:RangeValidator ID="RangeValidator1" runat="server" ErrorMessage="RangeValidator">



The id of the control to validate

Error Message

The text to display in the page when validation fails

Maximum Value

Specifies the maximum value of the input control

Minimum Value

Specifies the minimum value of the input control


Specifies the data type of the value to check. The types are:

<![if !supportLists]> ·         <![endif]>Currency

<![if !supportLists]> ·         <![endif]>Date

<![if !supportLists]> ·         <![endif]>Double

<![if !supportLists]> ·         <![endif]>Integer

<![if !supportLists]> ·         <![endif]>String


<asp:Label ID="Label1" runat="server" Text="NO OF Item"></asp:Label>
<asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
<asp:RangeValidator ID="RangeValidator1" runat="server"
  ControlToValidate="TextBox1" ErrorMessage="range should be between 5 to 10"
  MaximumValue="10" MinimumValue="5" SetFocusOnError="True" Type="Integer">
<asp:Button ID="Button1" runat="server" onclick="Button1_Click" Text="SUBMIT" />

When we will not enter value in the specified range then error message will show

RangeValidator Control in ASP.Net

When we enter the value in the specified range then page will execute

RangeValidator Control in ASP.Net

  Modified On Mar-22-2018 07:25:05 AM

Leave Comment