How to limit time range?

  • Profile Image
    penderparksrec
    Asked on May 14, 2019 at 04:46 PM

    I have a field in my form with time range. I am able to set up a condition that will hide the submit button and give a message if they try to choose a time before 7am. However, I am unable to setup a condition that works for the other part of the time range... the ending time. I want to also be able to hide the submit button and give a message if the second part of the range is after 10pm.

    Being that this is a RANGE of times... I need the condition to work on the "ending" time of the range as well as the "beginning" time of the range.

    For example - if someone tries to set the time range for 6am - 9am... they will get a message that it must be after 7am and the submit button is hidden. But 7am - 9am would work.

    But if they try to set the time range to 9pm - 11pm... they won't get the message and the submit button won't be hidden even though I have the condition setup for "After" 10pm.

    It appears that the condition only reads the time at the "beginning" of the range and not the "ending" of the range.

    Basically, the park hours are 7am - 10pm. You cannot request a time to use space in the park unless it falls within this range.

    Thanks in advance for your help!

     

  • Profile Image
    Jed_C
    Answered on May 14, 2019 at 09:02 PM

    1). But if they try to set the time range to 9pm - 11pm... they won't get the message and the submit button won't be hidden even though I have the condition setup for "After" 10pm.

    It won't work unless one of the time in the time range meets the condition. In your example, it still meets the condition of 9pm. It is still in the time range between 7am - 10pm.

    A workaround is to use the Time element and HIDE the Submit button using conditions if the Time element is not in the desired range.

    1. Add a Time element and set the Time Format to 24 HOURS.

    15270861151.png

    2. Add a Form Calculation Widget and set it to get the value from the Time field.

    15270862503.png

    3. Add a condition to HIDE the Submit button if the Calculation of time is not in the desired range.

    15270862992.png

    I have also added a condition to Show a warning message (Text element) if the Calculation of time is not in the desired range.

    15270863604.png

    I've applied the method above in a cloned version of your form. You can check it here https://form.jotform.com/91337838101960.

    1557882052time_range2.gif

    Feel free to clone if you want https://www.jotform.com/help/42-How-to-Clone-an-Existing-Form-from-a-URL.

    Let us know if you have any questions or if you need further assistance.