What is JotForm?
JotForm is a free online form builder which helps you create online forms without writing a single line of code. No sign-up required.
At JotForm, we want to make sure that you’re getting the online form builder help that you need. Our friendly customer support team is available 24/7.
We believe that if one user has a question, there could be more users who may have the same question. This is why many of our support forum threads are public and available to be searched and viewed. If you’d like help immediately, feel free to search for a similar question, or submit your question or concern.
Using Conditional Logic with a DateTime fieldAsked by geetaroro on January 01, 2016 at 01:34 AM
Hi. I'm trying to use Conditional Logic to disable certain checkbox fields in a registration form after a deadline has passed. For example, we'd like to disable registration for the event on 1/9/2016 on Thursday at 8pm before the event. According to your support forums I should be able to do that using a DateTime field, prepopulated with the current date & time, and conditional logic. However no matter what format I try to use for the time, the Conditional Logic seems to ignore it and only disables the field if I enter a date earlier than the cutoff date. In other words, I cannot pick a specific time (8pm) to disable the checkbox field, it only seems to work once the date is past the cutoff used.
Here's the form in question: https://form.jotform.com/53515403415952
For testing purposes I was using today at 8pm to attempt to disable the first registration checkbox; however it only disables it once I change the date to "12/30/2015", regardless of the time entered. According to what I've read, I should be able to enter something like "12/31/2015 at 08:00 PM", or "12/31/2015 at 20:00", and have it disabled (since the current time is being filled in as after 10:00 pm; however it is not being disabled for me. Probably by the time you look at this you'll have to clone the form and experiment to see what I'm experiencing.
In the final form the datetime field will be hidden, but it doesn't seem to matter if it is hidden or visible
Thanks for your help.
Unfortunately, the date value will not work in conditional logic if you have the time value on it. Noticed in the "information" message that it will only read dates in "YYYY-MM-DD" format, no time on it.
However, I do have a workaround in mine, you'll need to have separate date field and time field in your form.
Here's an example:
- Have a date field value set to current
- Have a time field value set to current and in 24 hour format
I have set the conditional logic below to hide the submit button when the date and time is on and after 2016-01-02 12:30 AM.
IF date is after 01/01/2016 AND time is after 0:30 (which is 12:30 AM) then HIDE the submit button.
Make sure to set "ALL" to match all the rules before triggering the "DO" statement.
You can check my test form here: https://form.jotform.com/60004296311948
Do let us know if you need more information on this.
Hi, Charlie. Thanks; I had seen a couple of examples on the forum where both the date and the time were used, so I was puzzled why it wasn't working. I had actually thought about trying your suggestion last night but I did not realize you could "AND" multiple conditions together and without that it wouldn't work.
The only change I had to make to your suggestion is because the date comparison is AFTER and not "EQUAL OR AFTER", I have to enter the date as one day earlier than the cutoff date; i.e. in order to have an entry disable today (1/1/2016) at 10:00 AM I actually have to have the conditions read:
IF DateTime Field AFTER 2015-12-31
IF Time Field after 10:00
IF ALL OF THE IF RULES ARE MATCHED
This is now working as I intended. Thanks very much for the help!
On behalf of my colleague Charlie, you're welcome.
We are glad to now your form is working fine now, feel free to contact us anytime if you need more help, we will be glad to assist you.