blog

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

Range Validator Control in ASP.NET

Uttam Misra5114 13-Jan-2011

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>

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

Leave Comment

Comments

Liked By