how to prevent user selecting past date from calender

<html xmlns=””&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
//if u want to assign null value to textbox uncomment following stmt
// document.getElementById(“TextBox1”).value = “”;
<form id=”form1″ runat=”server”>
<asp:ScriptManager ID=”ScriptManager1″ runat=”server” />

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

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


Leave a Reply

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

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

Google photo

You are commenting using your Google 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 )

Connecting to %s