Users Pricing

blog

home / developersection / blogs / range validator control in asp.net

Range Validator Control in ASP.NET

Uttam Misra 5481 13 Jan 2011 Updated 18 Sep 2014

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.

Example
<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>
    </form>

Uttam Misra

Information Technology

More than 18 years of working experience in IT sector. We are here to serve you best.