A bit of a newbie to Javascript so forgive my ignorance here!
I'm looking for some help on the Date Picker Please. I'm creating a form where a user can request changes for an employee however for the dates I need to restrict the option on the date picker to be either a Monday, Friday or 1st of every month only.
I've got it where it will only allow certain days as below, but how/can I also allow for the 1st of every month to be selected?
The simplest solution seems to be adding a validator to the field like this:
fd.rendered(function() {
fd.field('TransferDate').addValidator({
name: 'Confirm date',
error: 'Date can only be a Monday, Friday, or the 1st of the month',
validate: function(value) {
let valueDate = new Date(value);
if (valueDate.getDate() == 1 || valueDate.getDay() == 1 || valueDate.getDay() == 5) {
return true;
}
return false;
}
});
});