Monday 3 December 2012

calendar extender not to select previous date


ASPX PAGE:


<cc1:CalendarExtender ID="CalendarExtender1" runat="server" TargetControlID="txtDatePersonal" OnClientDateSelectionChanged="checkDate">
                                    </cc1:CalendarExtender>


then add this script in same aspx page or master page


<script type="text/javascript">
        function checkDate(sender, args) {
            var toDate = new Date();
            toDate.setMinutes(0);
            toDate.setSeconds(0);
            toDate.setHours(0);
            toDate.setMilliseconds(0);
            if (sender._selectedDate < toDate) {
                alert("You can't select day earlier than today!");
                sender._selectedDate = toDate;
                //set the date back to the current date
                sender._textbox.set_Value(sender._selectedDate.format(sender._format))
            }
        }
    </script>

No comments:

Post a Comment