Friday, 15 November 2013

Restrict Ajax Calender future and past date using javascript

<script type="text/ecmascript">

    function checkDates(sender, args) {
       // alert(sender._selectedDate + "    enter    " + new Date());
        if (sender._selectedDate > new Date()) {
            alert('Date must be less than Today');
            sender._selectedDate = new Date();
            // set the date back to the current date
            sender._textbox.set_Value(sender._selectedDate.format(sender._format))
        }
    }
</script >

//HTML
 <asp:TextBox runat="server"  ID="dtForm"  Enabled="False" ></asp:TextBox>

<asp:CalendarExtender ID="CalendarExtender1" runat="server" PopupButtonID="cal_Surveyor"
TargetControlID="dtForm" OnClientDateSelectionChanged="checkDates"  Enabled="True" Format="dd/MM/yyyy"></asp:CalendarExtender>

No comments:

Post a Comment

How to highlight selected text in notepad++

  –> To highlight a block of code in Notepad++, please do the following steps step-1  :- Select the required text. step-2  :- Right click...