Question
How to validate a date picker component by editing from source code?
12:45 Apr 13, 2026
"usr.FutureDateValidator": { validator: function (config) { return function (control) { let value = control.value; // This part right here // if (value.readonly) { return null; } let selectedDate = value instanceof Date ? value : new Date(value); let today = new Date(); today.setHours(0, 0, 0, 0); selectedDate.setHours(0, 0, 0, 0); let valueIsCorrect = selectedDate >= today; return valueIsCorrect ? null : { "usr.FutureDateValidator": { message: config.message } }; }; }, params: [{ name: "message" }], async: false }
This is a custom validation I made to validate a "Date Picker" component only for today and the following days. So it is unable to use past dates.
The problem occured when modifying the field's value after I save, then modifying another field that is not the date picker, it will run this custom validation again. So if the data was saved the previous days, this custom validation will validate that date picker field.
The question is how do I read the value's "Read-Only" so I can turn off the validation when its value is 'true'?
Or if there is a better way to configure this validation, I will be happy to change it.
Notes:
- This is a custom package (outside creatio's source package)
- Validate this field before it is saved
- After saving, the validation is turned off
- More than one is using this validation
- If possible, can edit it ONLY when the field (date picker) is edited (not other fields)
Thanks for helping, ask me more questions if the information is not enough.
Like
0 comments