How to show only before dates in JTSAGE date picker

泄露秘密 提交于 2019-12-13 16:25:11

问题


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}'/>

refer this Fiddle Demo


回答1:


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();
        }
   }
});

Updated FIDDLE



来源:https://stackoverflow.com/questions/24430461/how-to-show-only-before-dates-in-jtsage-date-picker

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!