New to Kendo UI for Angular? Start a free 30-day trial

Disabled Dates

The DateTimePicker allows you to disable the selection of specified dates by providing a disabledDates value to the component.

The DateTimePicker supports the following approaches for disabling dates:

  • Using a functionThe format for this input is (date: Date) => boolean. The approach disables each date for which the provided function returns true.
  • Using an array of datesThe format for this input is Date[]. The approach disables only the dates that are explicitly listed.
  • Using an array of daysThe format for this input is Day[]. The approach disables the specified days of the week.

You can also prevent the user from entering disabled dates with typing.

Using a Function

The following example demonstrates how to provide a function to disable every even date in the DateTimePicker.

Example
View Source
Edit In Stackblitz  
Change Theme:

Using a Date Array

The following example demonstrates how to provide an array of dates to disable the listed dates.

Example
View Source
Edit In Stackblitz  
Change Theme:

Using a Day Array

The following example demonstrates how to provide an array of Day enum values to disable the listed days of the week, that is, the days of the weekend.

import { Day } from '@progress/kendo-date-math';

@Component({
  selector: 'my-app',
  template: `
    <kendo-datetimepicker
      [(ngModel)]="value"
      [disabledDates]="disabledDates"
    >
    </kendo-datetimepicker>
  `
})
export class AppComponent {
  public value: Date;
  public disabledDates: Day[] = [Day.Saturday, Day.Sunday];
}

Preventing Invalid Input

The DateTimePicker input doesn't prevent the user from entering dates, which are marked as disabled, with typing.

To avoid this behavior, use either of the following options:

  • Set the readOnlyInput property of the DateTimePicker to true, allowing in this way the user to choose a date only from the popup Calendar (see example).
  • Use the built-in disabled dates validation to notify users that their input is invalid (see example).

By default, forms validation is enabled. To disable it, set the disabledDatesValidation property to false.

Example
View Source
Edit In Stackblitz  
Change Theme: