Input checking - check if start date is less than end date

I don`t know which features I should use to implement this type of checking. I have got two properties for entity - startDate and endDate. On edit screen i want to check whether startDate is less than endDate. If not, disable button for completing action (Save or Add) and mark input field as invalid. Can you help me and point me to the features which might be useful in my case?

Thank you in advance.


Add your logic to postValidate method before commt entity.
The save button remains active. After clicking, the screen controller performs checks and displays a common message with errors that the user must correct. Messages can be customized and i18n.

Thank for your reply.
So there is no way to achieve check of dates after DateField component lose focus in some convenient way - without too much CSS work and manually writing controller to disable buttons and show messages like Bootstrap help blocks below input field?
If the answer is no, i will use your suggested approach.

You can add a hidden component to display the error message.
Add the validator to the field in the code of which to set the display of the hidden element if the condition is not met. Program call Component.Validatable.validate (). Think for users it is better to use everywhere a uniform approach, built into the platform.

Ok I understand that using built in approach is better but i was curious :smiley:. So I used postValidate() method to validate dates and everything works fine, but is there a way to format validation errors to be more noticable? Because right now they are displayed in bottom right corner of screen and I almost do not notice them when i submit form with wrong data.

See this How can I change position of alert message box - CUBA.Platform