Search results

Date Range

The DatePicker provides an option to select a date value within a specified range by using the Min and Max properties. Always the Min value has to be lesser than the Max value.

The Value property depends on the Min/Max with respect to the StrictMode property. For more information about StrictMode, refer to the Strict Mode section from the documentation.

The following code allows selecting a date within the range from 7th to 27th in a month.

@using Syncfusion.EJ2.Blazor.Calendars

<EjsDatePicker Min='@MinDate' Max='@MaxDate' Value='@DateValue'></EjsDatePicker>

@code {
    public DateTime MinDate {get;set;} = new DateTime(DateTime.Now.Year,DateTime.Now.Month,07);
    public DateTime MaxDate {get;set;} = new DateTime(DateTime.Now.Year, DateTime.Now.Month, 27);
    public DateTime DateValue {get;set;} = new DateTime(DateTime.Now.Year, DateTime.Now.Month, 15);
}

The output will be as follows.

datepicker

When the Min and Max properties are configured and the selected date value is out-of-range or invalid, then the model value will be set to out of range date value or null respectively with highlighted error class to indicate the date is out of range or invalid.

@using Syncfusion.EJ2.Blazor.Calendars

<EjsDatePicker Min='@MinDate' Max='@MaxDate' Value='@DateValue'></EjsDatePicker>

@code {
    public DateTime MinDate {get;set;} = new DateTime(DateTime.Now.Year,DateTime.Now.Month,07);
    public DateTime MaxDate {get;set;} = new DateTime(DateTime.Now.Year, DateTime.Now.Month, 27);
    public DateTime DateValue {get;set;} = new DateTime(DateTime.Now.Year, DateTime.Now.Month, 28);
}

The output will be as follows.

datepicker

 If the value of Min or Max properties changed through code behind, you have to update the Value property to set within the range.