如何允许使用Ajax Date扩展程序在日历中仅选择一个上一个日期和当前日期 [英] how to allow to select only one previous date and current datein calendar with Ajax Date extender

查看:85
本文介绍了如何允许使用Ajax Date扩展程序在日历中仅选择一个上一个日期和当前日期的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在我的asp.net网站上使用Ajax日历扩展器,

我想要一个日历,其中用户应该选择两个日期中的任何一个,如1).CurentDAte或2)一个前一个日期之前的当前日期日期..

以下代码..我只能选择当前日期,但无法在当前日期之前选择一个优惠日期...



i am using Ajax calendar extender in my asp.net site,
I want a calender in which user should select either of two dates like 1).CurentDAte or 2)one Previous date before current date ..
in following code ..i am able to select only current date ,but cant select one previos date before current date...

function checkDate1(sender, args) {
       var toDate= new Date();
           toDate.setMinutes(0);
           toDate.setSeconds(0);
           toDate.setHours(0);
           toDate.setMilliseconds(0);
           if (sender._selectedDate < toDate) {
               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))
           }
if (sender._selectedDate > new Date()) {
               alert("You cannot select a day greater than today!");
               sender._selectedDate = new Date();
               // set the date back to the current date
               sender._textbox.set_Value(sender._selectedDate.format(sender._format))
           }
       }

推荐答案

您可以在创建页面时始终设置日历的开始日期和结束日期。



You could always set the Start and End dates of the calendar when you create the page.

csCalendar.StartDate = DateTime.Now.AddDays(-1);
csCalendar.EndDate = DateTime.Now;





这会将日历限制为仅允许选择当前日期和上一个日期。



This will restrict the calendar to only allow selection of the current date and the previous date.


这篇关于如何允许使用Ajax Date扩展程序在日历中仅选择一个上一个日期和当前日期的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆