Range validator for Date type value : RangeValidator « Validation by Control « ASP.Net






Range validator for Date type value


<script runat="server" language="C#" >
protected void Page_Load(object o, EventArgs e) {
    if(IsPostBack && rangeValidator.IsValid ){
        message.Text = "Thanks, see you in September.";
    }
    else {
        message.Text = "Please start vacations on 2008/08/01";
    }
}
</script>
<form runat="server">
Enter your desired vacation start date:
<asp:Textbox runat="server" id="theDate" />
<asp:RangeValidator runat="server"
    id="rangeValidator"
    ControlToValidate="theDate"
    ErrorMessage="vacations must start on August 1st" 
    Type="Date"
    MinimumValue="2008/08/01"
    MaximumValue="2008/08/01"
/><br />
<b><asp:label runat="server" id="message" /></b>
<br /><asp:button type="submit" runat="server" Text="Submit" />
</form>

 








Related examples in the same category

1.Validation test: range (C#)
2.Rangevalidator: Enter an integer between 0 and 100 (VB.net)
3.RangeValidator Demo: The Quantity field must be from 1 to 30! (VB.net)
4.RangeValidator for integer type value
5.Set Focus On Error