禁用 Jquery 日期选择器中的日期

发布于 2024-09-24 14:32:56 字数 92 浏览 0 评论 0原文

我正在使用 jquery 日期选择器和时间选择器。在日期选择器中,我想禁用当前日期之前的所有日期。在时间选择器中,我想显示当前时间前一小时的时间。有人能告诉我该怎么做吗?

I am using a jquery datepicker and timepicker. In datepicker I want to disable the all dates which are past to the current date. And in timepicker I want to show the times which is one hour prior to the current time.Can anyone tell me how to do this?

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

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

发布评论

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

评论(1

软糖 2024-10-01 14:32:56

这是答案的一部分。

此 DatePicker http://jqueryui.com/demos/datepicker/#min-max 提供 minDate 和 maxDate 选项。

<script>
$(function() {
    $( "#datepicker" ).datepicker({ minDate: -20, maxDate: "+1M +10D" });
});
</script>

将开始日期和结束日期设置为
实际日期(新日期(2009, 1 - 1,
26)),作为从今天开始的数字偏移
(-20),或作为一串句点和
单位('+1M +10D')。最后,使用
“D”代表天,“W”代表几周,“M”代表
月,或“Y”年。

就像尼克说的那样,有太多的时间选择器/日期选择器,我们不知道你在谈论哪些。更新问题,您将获得更好的帮助...除非您当然已经弄清楚了:)

Here's part of the answer.

This DatePicker http://jqueryui.com/demos/datepicker/#min-max offers a minDate and maxDate option.

<script>
$(function() {
    $( "#datepicker" ).datepicker({ minDate: -20, maxDate: "+1M +10D" });
});
</script>

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'). For the last, use
'D' for days, 'W' for weeks, 'M' for
months, or 'Y' for years.

Like Nick said, there are too many timepickers/datepickers out there to know which ones you are talking about. Update the question and you'll get better help... unless you've already figured it out of course :)

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文