【问题标题】:How can we make all the past dates in the calendar unselectable?我们怎样才能使日历中所有过去的日期都无法选择?
【发布时间】:2023-03-26 08:55:02
【问题描述】:

我有一个type="datetime" 的html5 日历。我希望过去的日期无法选择。

<input  class="form-control" type="datetime" date-time auto-close="true" view="date"
datepicker-options="dateOptions" min-view="date" maxlength="10" format="dd/MM/yyyy" 
ng-model="$ctrl.DateInput" required="true">

矩形内的所有日期都应处于禁用状态。

有人可以帮我吗?

【问题讨论】:

  • 你试过min="new Date()"吗?

标签: javascript angularjs html twitter-bootstrap


【解决方案1】:

使用Javascript,您可以设置日期控件的min 属性。您也可以从您的 ViewModal 中进行设置。

var today = new Date().toISOString().split('T')[0];
document.getElementsByName("date-control")[0].setAttribute('min', today);
&lt;input name="date-control" type="date"&gt;

【讨论】:

  • 是的..这是确切的解决方法; recalll.co/app/…
  • 我正在使用 angular js ..我不能按名称使用 document.getElement ..在我的情况下,日历与 scrrenshot 中的不同..在这种情况下我怎样才能使它工作跨度>
  • 将您的 ng-model 设为对象并将其绑定到 min 属性。
  • 你能举个例子吗
  • @KishoreKumar 在上面的代码中,我们没有将日历显示为我粘贴的 img ..您是否可以使用上述功能获取日期选择器
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2013-02-05
  • 1970-01-01
  • 2017-07-19
  • 1970-01-01
  • 2021-02-16
  • 1970-01-01
相关资源
最近更新 更多