我们怎样才能使日历中的所有过去日期无法选择? [英] How can we make all the past dates in the calendar unselectable?

查看:177
本文介绍了我们怎样才能使日历中的所有过去日期无法选择?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

I had a html5 calender of type="datetime". I want the past dates to make unselectable.

<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">

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

All the dates inside the rectangle should be in disable state.

有人可以帮助我吗?

推荐答案

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

With Javascript, you can set the min attribute of the date control. You can also set this from your ViewModal.

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

<input name="date-control" type="date">

这篇关于我们怎样才能使日历中的所有过去日期无法选择?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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