In the WS Form Facebook group, a user asks:
I’m trying to compare one date field to another one using conditional logic although when you select “is greater than” the second field doesn’t give you a choice of other fields in the form, it’s just a text box so I tried putting #field(332) but that doesn’t appear to work.
Is there something I’m missing?
WS Form is one of the most powerful WordPress forms plugins.
In this article, I share my findings as I tried to solve the above puzzle and share a JSON export of a working form so you can observe/modify/learn from it. There’s probably a simpler way of achieving the same; if so, do share.
We shall add an HTML field and update its HTML to show the comparison result.
To check if dates are equal
Use “Matches field”.
Also, set at least 1 of the date fields (being compared) to not be blank. This is to ensure that the comparison check result message does not appear on page load when both fields are empty (are technically equal in value).
To check if Date 1 > Date 2 or Date 2 > Date 1
Create two hidden Number fields whose values are set to the corresponding date fields.