Problem is, how to disable selectable on PAST DATES in fullcalendar\'s month/week view.
I want to user not allowed to click/select the on past dates.
No need for a long program, just try this.
checkout.setMinSelectableDate(Calendar.getInstance().getTime());
Calendar.getInstance().getTime()
Gives us the current date.
I have been using validRange
option.
validRange: {
start: Date.now(),
end: Date.now() + (7776000) // sets end dynamically to 90 days after now (86400*90)
}
below is the solution i'm using now:
select: function(start, end, jsEvent, view) {
if (moment().diff(start, 'days') > 0) {
$('#calendar').fullCalendar('unselect');
// or display some sort of alert
return false;
}
if any one of answer is not work for you please try this i hope its work for you.
select: function(start, end, allDay) {
var check = formatDate(start.startStr);
var today = formatDate(new Date());
if(check < today)
{
console.log('past');
}
else
{
console.log('future');
}
}
and also create function for date format as below
function formatDate(date) {
var d = new Date(date),
month = '' + (d.getMonth() + 1),
day = '' + d.getDate(),
year = d.getFullYear();
if (month.length < 2) month = '0' + month;
if (day.length < 2) day = '0' + day;
return [year, month, day].join('-');
}
i have tried all above question but not work for me
you can try this if any other answer work for you.
thanks
Thanks to this answer, I've found the solution below:
$('#full-calendar').fullCalendar({
selectable: true,
selectConstraint: {
start: $.fullCalendar.moment().subtract(1, 'days'),
end: $.fullCalendar.moment().startOf('month').add(1, 'month')
}
});
In FullCalendar v3.0, there is the property selectAllow:
selectAllow: function(info) {
if (info.start.isBefore(moment()))
return false;
return true;
}