A timepicker form item marked as required seems to not get validated correctly when there is a leading ZERO in the minute part.
For example:
16:05 doesn’t get validated because the minute part starts with ZERO.
A timepicker form item marked as required seems to not get validated correctly when there is a leading ZERO in the minute part.
For example:
16:05 doesn’t get validated because the minute part starts with ZERO.
Hello Nikolai,
First of all, my apologies for the very late reply on this thread.
Regarding your question:
Do you still have an issue with the timepicker validation? If yes, could you share a configuration that reproduces it? I tested it with a minimal setup, and it seems to work correctly: DHTMLX Snippet Tool
The problem seems to appear when you have the valueFormat property in the configuration object:
const timePickerConfig = {
type: "timepicker",
name: "time",
label: "Time",
required: true,
timeFormat: 24,
editable: true,
value: "16:05",
valueFormat: "timeObject"
};
Hello @Nikolai_Dimentiev,
Thank you for clarification. It seems like built-in validation works inconsitetnly for this case. I already sent it to the dev team, and will notify you on any udpates.
Currently it can be avoided by custom validation, like follows:
const timePickerConfig2 = {
type: "timepicker",
name: "time2",
label: "Time",
required: true,
timeFormat: 24,
editable: true,
valueFormat: "timeObject",
validation: (value) => {
if (value == null || value === "") return false;
if (typeof value !== "object") return false;
const hour = Number(value.hour);
const minute = Number(value.minute);
if (!Number.isInteger(hour) || !Number.isInteger(minute)) return false;
if (hour < 0 || hour > 23) return false;
if (minute < 0 || minute > 59) return false;
if (hour === 0 && minute === 0) return false;
return true;
}
};
Here is an example:
https://snippet.dhtmlx.com/0fh1nwgz
Kind regards,