How to add validation rule to date and time field

Hi, I need to make a validation of one form field, user enters start date-and-time and end date-and-time and then needs to enter an integer number, I have to validate on the form that the entered number is smaller or equal to the difference of end date-and-time minus start date-and-time?

I created a JS that throws an alert if the entered number is larger, but I still can not validate the field and prevent the user from submitting the form.

Can I somehow use the output from "Event rule" for validation?

Help please?

OriginalPostID-22392

OriginalPostID-22392

  Discussion posts and replies are publicly visible