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