如何只显示在JTSAGE日期选择器之前的日期 [英] How to show only before dates in JTSAGE date picker
问题描述
我在我的移动应用程序(jquery mobile和phonegap)中使用 Jtsage 日期选择器。我想仅在今天和今天之前显示日期(隐藏未来日期
),所以我参考这个 documentaion 。在该文档中,他们提到 afterToday,beforeToday,notToday,minDays,maxDays 。我使用 beforeToday
为我的 datebox
但似乎不工作。
我的日期选择器调用是像:
I use Jtsage date picker in my mobile application(jquery mobile and phonegap). I want to show only today and before today date(hide future dates
) so i refer this documentaion. In that documentation they mention afterToday,beforeToday,notToday,minDays,maxDays. I use beforeToday
for my datebox
but it seems not working.
My date picker calling is like:
<input name="mydate" id="mydate" type="date" data-role="datebox" data-options='{"mode": "datebox", "useNewStyle":true,"afterToday":false,"beforeToday":true,"maxDays": 1}'/>
参考这个小提琴演示
推荐答案
一种方法是添加一个事件来捕捉'set'。如果日期设置在将来,弹出消息并停止ImmediatePropagation:
One way is to add an event to catch the 'set'. If date being set is in the future, popup a message and stopImmediatePropagation:
$('#mydate').on('datebox', function (event, payload) {
if (payload.method === 'set') {
var startdate = new Date();
if (payload.date > startdate) {
window.alert('You cannot select future dates!');
e.stopImmediatePropagation();
}
}
});
更新 FIDDLE
Updated FIDDLE
这篇关于如何只显示在JTSAGE日期选择器之前的日期的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!