DatePicker: Set current month values

Hi,

Would it be possible to set the current month values in a date picker?

We're currently in November 2024, how can I set the date picker field to only show November 2024 dates? Then when December, roles around, how do I set only Decembers' dates?

fd.field('Date1').widgetOptions = {
    min: new Date(minDate),
    max: new Date(maxDate)
}

var today = new Date();
var minDate = new Date(today.getFullYear(), today.getMonth(), 1);
var maxDate = new Date(today.getFullYear(), today.getMonth() + 1, 0);

The date picker is blank for some reason when using this code.

Thank you!

Hi @Qman,

You need to set the minDate and maxDate values before applying them to the date picker. The full code should look something like this:

fd.rendered(() => {
    var today = new Date();
    var minDate = new Date(today.getFullYear(), today.getMonth(), 1);
    var maxDate = new Date(today.getFullYear(), today.getMonth() + 1, 0);
    
    fd.field('Date1').widgetOptions = {
        min: new Date(minDate),
        max: new Date(maxDate)
    }
});