Can a require a time gap between two times entered?

  • DCYFnutrition
    Asked on January 23, 2020 at 7: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?

    Jotform Thread 2130153 Screenshot
  • David JotForm Support Manager
    Replied 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 Screenshot 10

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

    1579836490condition Screenshot 21

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

    1579836554result Screenshot 32

    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.

  • DCYFnutrition
    Replied on January 24, 2020 at 3: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?

  • David JotForm Support Manager
    Replied on January 24, 2020 at 5: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 Screenshot 10

    And set up this conditions:

    1579904961conditions 001 Screenshot 21

    Example: 

    1579905065example Screenshot 32

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