Asp.Net Ajax Calendar Control Validation For Date

To make Validation for Ajax Calendar so that usec cannot install Greater than or Less than Todays; date

This exammple demonstates Date Must not greater than Today’s Date

<asp:TextBox CssClass=”stdtextboxwidth” ID=”txtDate” runat=”server” Width=”180px”></asp:TextBox>
<cc1:CalendarExtender ID=”CalendarExtender1″ runat=”server” TargetControlID=”txtDate”
PopupButtonID=”imgDate” OnClientDateSelectionChanged=”checkDate”>
</cc1:CalendarExtender>
<img alt=”Calendar” src=”images/Calendar.png” id=”imgDate” />

Put Following Code into Javascript
<script type=”text/javascript”>
function checkDate(sender,args)
{
var dt = new Date();
if(sender._selectedDate > dt)
{
sender
._textbox
.set_Value(dt.format(sender._format));
alert(“You cannot Select Date Greater than Today”);
}

}
</script>

Advertisement

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 )

Connecting to %s