Comparing Dates in WS Form

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.

calc(#field(22))

and

calc(#field(23))

Then

and

Form JSON Export

JSON link

Get access to all 524 Bricks code tutorials with BricksLabs Pro

Leave the first comment

 

Related Tutorials..

Dynamic Landing Pages Redirection Based on User Input using WS Form

Dynamic Landing Pages Redirection Based on User Input using WS Form

Use the Conditional Logic & Actions in WS Form Pro to redirect the user depending on what they input.
Categories:
Tags:
Populating WS Form Field in a Modal with Button Data Attribute in Bricks

Populating WS Form Field in a Modal with Button Data Attribute in Bricks

How a WS Form field inside of a Modal can be pre-filled by clicking the button to open it.
Categories: