I am using FullCalendar.js for a date selector on my web page.
I want to limit the range of selectable dates on my full calendar widget to one day only
(the default is to drag for multiple dates, or click for a single date). I'd like to effectively disable the drag functionality for selecting multiple dates, either by:
- Disabling the native drag event (probably incorrect)
- Restrict the date range of selectable dates to one day (this feels more sensible)
This question has answers on how to limit date selection to one day using the week view by specifying start
and end
in the selectConstraint
option. However, the same solution does not work for the month view.
How can I limit the date selection range to one day for month view?
My Code:
var calendar = new FullCalendar.Calendar(calendarEl, {
plugins: [ 'interaction', 'dayGrid', 'timeGrid' ],
selectable: true,
header: {
left: 'prev,next ',
center: 'title',
right: ''
},
validRange: {
start: today
},
selectConstraint:{
start: '00:01',
end: '23:59',
},
dateClick: function(info) {
custom_date = true;
$("#start_date").val(info.dateStr);
$("#end_date").val(info.dateStr);
}
});