Skip to main content

beforeChange

fires before the change of date selection

beforeChange: (date: Date, oldDate: Date, byClick: boolean) => boolean | void;

Parameters:

  • date: Date - the newly selected date. If the selection is about to be cleared, an empty string
  • oldDate: Date - the previously selected date
  • byClick: boolean - defines whether the change happened because of a click on a date or on the "today" or "clear" control - true, or due to an API call - false

Returns:

Return true to allow changing date selection, false to prevent changing date selection.

Example

calendar.events.on("beforeChange",function(date, oldDate, byClick){
if (date > new Date())
return false;
});

You can block selection of particular dates by returning false from the event handler.

Related sample: Calendar. Events

Related API:

Related article: Event handling