Using Conditional Logic with a DateTime field

  • geetaroro
    Asked on January 1, 2016 at 1: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.

      -Roland

  • Charlie
    Replied on January 1, 2016 at 11:46 AM

    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.

    Using Conditional Logic with a DateTime field Image 1 Screenshot 50

     

    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

    Using Conditional Logic with a DateTime field Image 2 Screenshot 61

     

    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.

    Condition:

    IF date is after 01/01/2016 AND time is after 0:30 (which is 12:30 AM) then HIDE the submit button.

    Using Conditional Logic with a DateTime field Image 3 Screenshot 72

    Make sure to set "ALL" to match all the rules before triggering the "DO" statement.

    Using Conditional Logic with a DateTime field Image 4 Screenshot 83

     

    You can check my test form here: https://form.jotform.com/60004296311948 

     

    Do let us know if you need more information on this.

  • geetaroro
    Replied on January 1, 2016 at 4:40 PM

    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

    DISABLE (etc)

     

    This is now working as I intended. Thanks very much for the help!

  • Kevin Support Team Lead
    Replied on January 1, 2016 at 7:39 PM

    Hi,

    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.

    Regards.