Can a require a time gap between two times entered?

  • Profile Image
    DCYFnutrition
    Asked on January 23, 2020 at 07:02 PM

    I am creating an application where I need to know the start time for 2 meal services, but it is required that the start times must be 3 hours apart and the meals times cannot overlap. Is there a way to put this restriction on the application?

  • Profile Image
    BDAVID
    Answered on January 23, 2020 at 10:30 PM

    Hi, probably the only close solution would be calculating the difference with a Form Calculation widget: https://www.jotform.com/help/259-How-to-Perform-Form-Calculation-Using-a-Widget

    1579836393difference.png

    Then, create a condition to show a warning and hide the submit button:

    1579836490condition.png

    Result: https://form.jotform.com/200228747395056

    1579836554result.gif

    Unfortunately, there is no way to prevent that the "Until" part of the "Snack service" overlaps with the start time of the "Lunch Service". Let us know if you have more questions.

  • Profile Image
    DCYFnutrition
    Answered on January 24, 2020 at 03:39 PM

    Thank you for your help. The widget works if snack service is always before lunch. But what if there is the possibility that the snack happens after lunch as well? The numbers become negative. Is there a way to get around that?

  • Profile Image
    BDAVID
    Answered on January 24, 2020 at 05:31 PM

    I think I found a workaround, please test this form: https://form.jotform.com/200236707103947

    I basically added another Form Calculation widget to turn the negative value to positive:

    1579904907turn.png

    And set up this conditions:

    1579904961conditions_001.png

    Example: 

    1579905065example.gif

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