如果在日历扩展程序中选择了从日期开始,那么需要从日期日历中清除之前的日期,如图所示。请提供您的意见清除结束日期中的早期日期使用ajaxControlToolkit的日历:calendarExtender
回答
使用该CSS属性上的任何的CSS类
.ajax__calendar_day_disabled
{
background-color:#ccc !important;
color:#eee !important;
}
使用上述CSS类日期文本框像CssClass="disable_past_dates"
并使用脚本
function getElementsByClassName(a, b) { var c = []; var d = a.getElementsByTagName("*"); for (var e = 0; e < d.length; e++) { if (d[e].className.indexOf(b) != -1) { c.push(d[e]) } } return c } function DisableDates(a) { if (a._element.className.indexOf("disable_past_dates") != -1) { var b = getElementsByClassName(a._days, "ajax__calendar_day"); var c = (new Date).setHours(0, 0, 0, 0); for (var d = 0; d < b.length; d++) { try { if (b[d].date.setHours(0, 0, 0, 0) >= c) { b[d].className = "ajax__calendar_day" } else { b[d].className = "ajax__calendar_day ajax__calendar_day_disabled" } } catch (e) { } } } if (a._element.className.indexOf("disable_future_dates") != -1) { var b = getElementsByClassName(a._days, "ajax__calendar_day"); var c = (new Date).setHours(0, 0, 0, 0); for (var d = 0; d < b.length; d++) { try { if (b[d].date.setHours(0, 0, 0, 0) <= c) { b[d].className = "ajax__calendar_day" } else { b[d].className = "ajax__calendar_day ajax__calendar_day_disabled" } } catch (e) { } } } } AjaxControlToolkit.CalendarBehavior.prototype.show = function (a) { this._ensureCalendar(); if (!this._isOpen) { var b = new Sys.CancelEventArgs; this.raiseShowing(b); if (b.get_cancel()) { return } this._isOpen = true; this._popupBehavior.show(); if (this._firstPopUp) { this._switchMonth(null, true); switch (this._defaultView) { case AjaxControlToolkit.CalendarDefaultView.Months: this._switchMode("months", true); break; case AjaxControlToolkit.CalendarDefaultView.Years: this._switchMode("years", true); break } this._firstPopUp = false } this.raiseShown(); DisableDates(this) } }; AjaxControlToolkit.CalendarBehavior.prototype._cell_onclick = function (a) { a.stopPropagation(); a.preventDefault(); if (!this._enabled) return; var b = a.target; var c = this._getEffectiveVisibleDate(); Sys.UI.DomElement.removeCssClass(b.parentNode, "ajax__calendar_hover"); switch (b.mode) { case "prev": case "next": this._switchMonth(b.date); break; case "title": switch (this._mode) { case "days": this._switchMode("months"); break; case "months": this._switchMode("years"); break } break; case "month": if (b.month == c.getMonth()) { this._switchMode("days") } else { this._visibleDate = b.date; this._switchMode("days") } break; case "year": if (b.date.getFullYear() == c.getFullYear()) { this._switchMode("months") } else { this._visibleDate = b.date; this._switchMode("months") } break; case "day": if (this._element.className.indexOf("disable_past_dates") != -1) { if (b.date.setHours(0, 0, 0, 0) >= (new Date).setHours(0, 0, 0, 0)) { this.set_selectedDate(b.date); this._switchMonth(b.date); this._blur.post(true); this.raiseDateSelectionChanged() } } else if (this._element.className.indexOf("disable_future_dates") != -1) { if (b.date.setHours(0, 0, 0, 0) <= (new Date).setHours(0, 0, 0, 0)) { this.set_selectedDate(b.date); this._switchMonth(b.date); this._blur.post(true); this.raiseDateSelectionChanged() } } else { this.set_selectedDate(b.date); this._switchMonth(b.date); this._blur.post(true); this.raiseDateSelectionChanged() } break; case "today": this.set_selectedDate(b.date); this._switchMonth(b.date); this._blur.post(true); this.raiseDateSelectionChanged(); break } DisableDates(this) };
这将禁用所有过去的日期,但不清除它。
试试这个,
CntrlID.MinDate = DateTime.Now;
CntrlID.MaxDate = DateTime.Today.AddMonths(12);
CntrlID.MaxDate = DateTime.Today.AddYears(100);
- 1. PG:使用起始日期日期和结束日期列
- 2. glyphicon日历开始和结束日期
- 3. 生成开始日期和结束日期之间的日期
- 4. 其中起始日期日期和结束日期
- 5. 在angularjs中查看完整日历中的开始日期和结束日期
- 6. 开始日期和结束日期datepicker
- 7. Satrt日期和结束日期验证
- 8. NHiberate Validator开始日期结束日期
- 9. 开始日期和结束日期
- 10. 将记录日期和结束日期
- 11. 本月的开始日期和结束日期以及本年的开始日期和结束日期
- 12. 如何使用日期函数获取日期的结束日期
- 13. 仅显示事件的完整日历的开始日期和结束日期
- 14. 在DatePicker插件中禁用日期比今日早的日期
- 15. 使用日期和日历
- 16. 将日期添加到日期并计算结束日期?
- 17. 日期验证 - 开始日期,结束日期MVC
- 18. 比较日期 - 结束日期应该大于开始日期
- 19. 查询日期根据开始日期和结束日期
- 20. 使用星期六作为星期结束日期计算oracle中的星期结束日期
- 21. LINQ VB.NET检查生效日期和结束日期之间的日期(结束日期可以为空)
- 22. UILocalNotification结束日期
- 23. Java中的日期/日历
- 24. 查询使用开始日期和结束日期获取可用日期
- 25. 自动使用基于结束日期的Excel填写日期
- 26. MVC获取日历开始日期和结束日期之间的天数
- 27. 在Google日历中为开始日期和结束日期之间的所有日期添加活动Android
- 28. jQuery中使用起始日期限制结束日期
- 29. 获取本周的开始日期和结束日期(星期一从星期一开始,星期日结束)
- 30. 开始日期和结束日期相同使用引导日期选择器