how to prevent user selecting past date from calender


<html xmlns=”http://www.w3.org/1999/xhtml”&gt;
<head id=”Head1″ runat=”server”>
<title>Calendar Extender</title>
<script type=”text/javascript”>
function checkDate(sender, args) {

if (sender._selectedDate < new Date()) {
alert(“You cannot select a day earlier than today!”);
sender._selectedDate = new Date();
// set the date back to the current date
sender._textbox.set_Value(sender._selectedDate.format(sender._format))
//if u want to assign null value to textbox uncomment following stmt
// document.getElementById(“TextBox1”).value = “”;
}
}
</script>
</head>
<body>
<form id=”form1″ runat=”server”>
<asp:ScriptManager ID=”ScriptManager1″ runat=”server” />
<div>

<asp:TextBox ID=”TextBox1″ runat=”server”></asp:TextBox>

<asp:calendarextender ID=”CalendarExtender1″
runat=”server” OnClientDateSelectionChanged=”checkDate”
TargetControlID=”TextBox1″ />

</div>
</form>
</body>
</html>

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s