I have set up a form where if the user sets up a date in past the user will be prompted with a confirmation box.
However sometimes the confirmation dialog box does not block the next step. If I click next on calendar box the confirmation will trigger again and sometimes the if statement does not sometimes hold true if I pick today's date.
async validateDateRequired(args) {
const value = args.value || "";
if (value.trim().length === 0) {
args.valid = false;
args.message = "Date required";
}
if (DayPilot.Date.today() > args.value) {
const modal = await DayPilot.Modal.confirm("Date scheduled in the pass. Continue?");
if (modal.canceled) {
args.valid = false;
args.message = "Valid date is required"
}
}
},
////////////
assignmentForm(title, groups) {
const form = [
{name: title},
{name: 'Group', id: 'group_id', type: 'select', options: groups, onValidate: this.validateGroupRequired },
{name: "Start date", id: "start", type: "date", dateFormat: "d/M/yyyy", onValidate: this.validateDateRequired },
];
return form;
},
////////
const form = this.assignmentForm(title, responseJson.data);
const modal = await DayPilot.Modal.form(form, item, { okText: 'Assign', cancelText: 'Close'});
if (modal.canceled) {
return;
}
api call