Dynamic date range

Hello,
I have a sharepoint date field that I want limit in a specific date range based on the actual year plus 10 years.
Example: today is 03/12/2024 and my field must accept only date until 03/12/2034.
How I can achieve that?
Thank you in advance.

Hi @stefano.mazzi,

You can use this example from our documentation. The code should look something like this:

fd.rendered(() => {
    let minDate = new Date();
    let maxDate = new Date();
    maxDate.setFullYear(maxDate.getFullYear() + 10);
    
    fd.field('DateField').widgetOptions = {
        min: new Date(minDate),
        max: new Date(maxDate)
    }
});
1 Like

Thank you @IliaLazarevskii
If I wanted to allow to enter document with a date less than today, how should I do it?

minDate.setFullYear(minDate.getFullYear() - 5);

Right?
Thank you.