Tuesday, March 11, 2014

Asp.NET Validation - RangeValidator

The RangeValidator control verifies that the input value falls within a predetermined range.

Example:-
Default.aspx


<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
</head>
<body bgcolor="White">
    <form id="form1" runat="server">
    <div>
    <h3>Date:<asp:TextBox runat="server" id="txtDate" />

        </h3>
        <br />

        <asp:RangeValidator
            runat="server" id="rngDate" controltovalidate="txtDate" type="Date"
            minimumvalue="01-01-2014" maximumvalue="31-12-2014"
            errormessage="Please enter a valid date within 2014!"
            BorderColor="#FF3399" BorderStyle="Ridge" ForeColor="Red" />
    </div>
    </form>
</body>
</html>

Output:


No comments:

Post a Comment