To ensure that the Finish Date is at least equal to or after Start Date, and not before; we should follow these steps:
- Add a Number field to your form (Label: Difference)
- Go to Conditional Rules and add two rules
- Calculate difference between two date fields:
- Conditions: When both date fields are present
- Action: Evaluate
differenceInMinutes({{date_2}}, {{date_1}})
and set the result to the Difference field.
- Show message is difference is negative:
- Condition: If the value of the Difference field is negative (less than 0)
- Action:
- Disable Submit Button (e.g. Disable Element .btn)
- Show an alert message (e.g. Show Element #my-message)
- Calculate difference between two date fields:
- Of course, you will need to add the alert message with the Form Builder > Snippet field:
<div id="my-message" style="display:none">Finish date should be equal to or after the start date.</div>
That’s it.