Pick multiple dates one by one with Jquery/Datepic

2019-06-26 06:14发布

I have a form and on that form I would like to have a datepicker. So when someone clicks select dates field the datepicker pops up and shows multiple months. From there I would like for the person to click individual dates, each click the date they selected gets appended to the form field comma seperated. Im looking for a jquery solution, right now Im looking at:

http://jqueryui.com/demos/datepicker/#multiple-calendars

The problem is when I select a date the datepicker closes then the date selected shows up in the form field. I want the datepicker to continue to show while they select multiple dates and the dates they selected stay highlighted, then click done when they are done selecting dates. Can anyone point me to how I can accomplish this or is there a pre-existing jquery code that does that?

2条回答
\"骚年 ilove
2楼-- · 2019-06-26 06:47

For anyone landing here trying to get multi date picker to highlight the dates selected- you can use the beforeshowday event like so to add a class.

NB: this will add a class to everything that Hasn't been selected yet, meaning you can style this normally and use the usual classes for your selected styling.

$( '#booking_date' ).multiDatesPicker({ 
        beforeShowDay: function(date) {
             return [true, 'myClass'];
      }
});
查看更多
【Aperson】
3楼-- · 2019-06-26 06:52

try out this plugin (demo near bottom of page): http://multidatespickr.sourceforge.net/

查看更多
登录 后发表回答