Home > DeveloperSection > Blogs > Range Validator Control in ASP.NET

Range Validator Control in ASP.NET

ASP.Net ASP.Net 
0 Comment(s)
 3627  View(s)
Rate this:


The RangeValidator control is used to check that the userenters an input value that falls between two values. It is possible to checkranges within numbers, dates, and characters.


<form id="form1"runat="server">

    <asp:TextBox ID="TextBox1" runat="server"

        style="z-index: 1; left: 60px; top: 55px; position: absolute"></asp:TextBox>

    <asp:Button ID="Button1" runat="server"

        style="z-index: 1; left: 96px; top: 109px; position: absolute" Text="Button" />


//applyingrange validator on TextBox1. Range should be between 20 to 50, otherwise itwill display error message.


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

        ErrorMessage="* value should be between 20 to 50"

        style="position:absolute; top: 159px; left: 60px; width: 209px;"

        ControlToValidate="TextBox1" MaximumValue="50" MinimumValue="20" Type="Integer"></asp:RangeValidator>


Don't want to miss updates? Please click the below button!

Follow MindStick