开发者

disabled past/previous dates from todays in Ajaxtoolkit calendar extendar?

开发者 https://www.devze.com 2023-01-28 03:24 出处:网络
disabled past dates from todays date// in Ajaxtoolkit calendar extendar ..开发者_运维百科.and show selected dates in format as 4-Dec-2010To prevent selecting dates earlier than today, add a JavaScript

disabled past dates from todays date// in Ajaxtoolkit calendar extendar ..开发者_运维百科.and show selected dates in format as 4-Dec-2010


To prevent selecting dates earlier than today, add a JavaScript function:

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))
    }
}

Then hook it up to the Calendar Extender:

<asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
<cc1:CalendarExtender ID="CalendarExtender1"
runat="server" OnClientDateSelectionChanged="checkDate" TargetControlID="TextBox1" />

You will also need a Validator to ensure the user does not manually set an invalid date.

0

精彩评论

暂无评论...
验证码 换一张
取 消