带有阻止日期的日历/日期选择器

发布于 2024-12-27 10:32:18 字数 160 浏览 3 评论 0原文

我目前正在开发一个订单系统,用户可以选择他们希望订单交付的日期。

我需要一个页面,其中日历/日期选择器始终可见(不是通过弹出窗口激活),并且所有过去的日期、今天的日期和未来 3 天的日期都被屏蔽。然后,用户可以从可用日期中进行选择,然后将其提交给客户。

任何帮助将不胜感激!

I am currently developing an order system where the user can select which day they would like their order to be delivered.

I need to have a page where a calendar/datepicker is visible (not activated by popup) at all times and has all past dates, todays date and 3 days into the future blocked out. The user can then select from the dates available which is then submitted to the client.

Any assistance would be much appreciated!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

属性 2025-01-03 10:32:18

检查以下链接:
http://jqueryui.com/demos/datepicker/#inline
http://jqueryui.com/demos/datepicker/#min-max

描述说:
“将开始日期和结束日期设置为实际日期 (new Date(2009, 1 - 1, 26))、作为距今天的数字偏移量 (-20) 或作为周期和单位的字符串('+1M +10D')"

Check the following links:
http://jqueryui.com/demos/datepicker/#inline
http://jqueryui.com/demos/datepicker/#min-max

The description says this:
"Set the beginning and end dates as actual dates (new Date(2009, 1 - 1, 26)), as a numeric offset from today (-20), or as a string of periods and units ('+1M +10D')"

空心↖ 2025-01-03 10:32:18

以下是如何始终显示日历的示例:

http://jqueryui.com/demos/datepicker/ #inline

看起来blackout-date功能可以通过beforeShowDay回调来实现,或者通过简单地设置日历最小/最大来实现。

http://jqueryui.com/demos/datepicker/#min-max

http://forum.jquery.com/topic/custom-callback-to-disable-specific-dates-in-datepicker

$('#datepicker').datepicker({..., beforeShowDay: allowedDates});

function allowedDates(date) {
      for (var i = 0; i < jsForbiddenDatesArray.length; i++) {
            if (date.getTime() == jsForbiddenDatesArray[i].getTime()) {
                  return [false, ''];
            }
      }
      return $.datepicker.noWeekends(date);
}

Here is an example of how to always display the calendar:

http://jqueryui.com/demos/datepicker/#inline

It looks like the blackout-date feature can be achieved through the beforeShowDay callback, or by simply setting the calendar min/max.

http://jqueryui.com/demos/datepicker/#min-max

http://forum.jquery.com/topic/custom-callback-to-disable-specific-dates-in-datepicker

$('#datepicker').datepicker({..., beforeShowDay: allowedDates});

function allowedDates(date) {
      for (var i = 0; i < jsForbiddenDatesArray.length; i++) {
            if (date.getTime() == jsForbiddenDatesArray[i].getTime()) {
                  return [false, ''];
            }
      }
      return $.datepicker.noWeekends(date);
}
谜泪 2025-01-03 10:32:18

它可以通过两种类型来完成:

  1. set mindate 和 maxdate
  2. 当您打开日期选择器并更改月份/年份时,它将在该月份和年份的每个日期触发一个事件 beforeShowDay ,您可以检查每个日期在该函数中使用日期范围数组或对象并返回 true 或 false。如果返回 false,则该日期将处于非活动状态,如果返回 true,则该日期将处于活动状态

it can be done by two types

  1. set mindate and maxdate
  2. when you open the datepicker and change month/year it will fire an event beforeShowDay with each date on that month and year, and you can check for each date in that function with your date range array or object and return true or false. If false return that date will be deactive and on true that date will be active
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文