I have a requirement where I need to show/hide dates based on users selection.
I have two SharePoint Date fields. One is the Effective Date field where the user will select the date they're going on a career break and the second is the Expected Return Date.
If the user selects 1/1/2023 in the Effective Date field, I want the Expected Return Date field to show only dates after 1/04/2023.
Filter Criteria: show only dates greater than 90 days once user selects date in Effective Date field.
var today = new Date();
var minDate = today.setDate(today.getDate()+2);
var maxDate = today.setDate(today.getDate()+30);
fd.field('Field1').widgetOptions = {
min: new Date(minDate),
max: new Date(maxDate)
}
You can change the settings of the Date field when another field value changes:
fd.field('Field1').$on('change', function(value) {
var selectedDate= new Date(value);
var minDate = today.setDate(selectedDate.getDate()+90);
fd.field('Field2').widgetOptions = {
min: new Date(minDate)
}
});