In this article we will learn how to use RangeValidator in or what is RangeValidator in or why use RangeValidator in with example.


ASP.NET RangeValidator is used to check whether input value is in given range or not.  it makes sure that the user input is within a specified range. You can use it to validate both numbers, strings and dates.

Let’s see Example:


<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="RangeValidator.aspx.cs"
Inherits="Example.RangeValidator" %>
<!DOCTYPE html>
<html xmlns="">
<head runat="server">
    <form id="form1" runat="server">
        Enter Amount:<br />
    <asp:TextBox runat="server" id="txtamount" /><br />
<asp:RangeValidator runat="server" id="rngamount" controltovalidate="txtamount"
Style="color:red;"type="Double" minimumvalue="0" maximumvalue="10000"
errormessage="Please enter a valid amount less than or equal 10000!" />
<br />
<br />


In above example if we entered minimum value zero and maximum value 10000 in textbox that’s valid. But we entered greater than 10000 that is invalid and give error message.



How to use RangeValidator in Asp.Net

I hope this article will help to you.

Leave a comment

Make sure you enter the (*) required information where indicated. HTML code is not allowed.

You may also like