How to validate between two time ranges in a Time widget

  • dhineshestfnsw
    Asked on August 25, 2020 at 2:32 AM

    In a Time widget we can set "TO" time in Range settings, But there is no validation between From time and To time. Please see the screenshot attached. Getting solution ASAP will be more helpful.

    Jotform Thread 2534300 Screenshot
  • Anita_K
    Replied on August 25, 2020 at 7:27 AM

    Hi,

    thank you for reaching out to us.

    Is this the form in question? https://www.jotform.com/201910629957058

    Can you please elaborate on the issue? I have tested the form, and it didn't let me submit it unless the second field "To" was also filled. Is this the issue you are experiencing?

    Looking forward to your reply.

  • dhineshestfnsw
    Replied on August 25, 2020 at 8:22 AM

    The issue is about, The "To" time sholud be lesser than "FROM" time.

    For ex: Based on screenshot attached  - 11 : 02 :AM to 05 : 03 : AM

    Here the "TO" time must be available only after ( 11 : 02 : AM ).

    But i can able to select the Past time ( 05 : 03 : AM ).

  • Anita_K
    Replied on August 25, 2020 at 10:35 AM

    Hi,

    thank you for clarifying. This can be achieved by adding a few extra fields and a couple of conditions.

    I've created a demo form for you, that you can check out here and you can also clone this to take a look at the conditions.

    1. First, we need to separate the output of the Time Field by using two Substring Widgets:

    How to validate between two time ranges in a Time widget Image 1 Screenshot 50How to validate between two time ranges in a Time widget Image 2 Screenshot 61

    2. Since the output of the Time field is text, we need to turn it into numbers, using two Calculation fields and two conditions:

    How to validate between two time ranges in a Time widget Image 3 Screenshot 72

    3. You can also add a Paragraph field to serve as an error message, this is optional.

    4. Finally, you can set up the condition that hides the Submit button if the "To" time is earlier than the "From" time

    How to validate between two time ranges in a Time widget Image 4 Screenshot 83

    Please give this a go and let us know how it goes.