What is JotForm?
JotForm is a free online form builder which helps you create online forms without writing a single line of code. No sign-up required.

At JotForm, we want to make sure that you’re getting the online form builder help that you need. Our friendly customer support team is available 24/7.

We believe that if one user has a question, there could be more users who may have the same question. This is why many of our support forum threads are public and available to be searched and viewed. If you’d like help immediately, feel free to search for a similar question, or submit your question or concern.


  • Profile Image

    Hidding submit button if the selected time is under 24 hours

    Asked by crhsbandwife on March 24, 2016 at 03:35 PM

    I want to hide the submit button if my form's "Absence Date/Start Time" is less than 24 hours away. How can I do this?

     

    https://form.jotform.com/60834216273150

     

    date and time JotForm
  • Profile Image
    JotForm Support

    Answered by Nik_C on March 24, 2016 at 05:16 PM

    You will have to create conditions that will be able to calculate if the date entered is older than 24 hours. I will get back to you as soon as I create those conditions for you.

  • Profile Image
    JotForm Support

    Answered by Nik_C on March 25, 2016 at 05:31 AM

    I tried creating the conditions for you. You will have to create the date and time fields where you will set the current time. You will then have to use calculation wizard to add the 24 hours to the time you get from the current time field. After that, you need to populate one field that will get the resulting date. 

    When you calculate the date you have to create a condition that will check if the date is before the current date + 24 hours.  

    Please take a look at this answer my colleague Charlie provided in this thread. You only have to change from 12:30 to the 24 hours. 

    Please let us know if you need any help with implementing this solution.

  • Profile Image

    Answered by crhsbandwife on April 14, 2016 at 03:15 PM

    Still needing help implementing, can you assist: https://form.jotform.com/61046011480139

  • Profile Image

    Answered by Ben on April 14, 2016 at 05:39 PM

    We would be happy to assist with the same, but I wanted to check this first with you:

    Date and Absence Starting Time are actually connected.

    So the time field is for the day that is selected in the date field.

    Absence Ending Time field is for the same date, just different time.

    If that is true, it would mean that we would first need to check if the day is less that tomorrow away or not, only then to check the time as well.

    This would be a bit different setup, but possible.

     

  • Profile Image

    Answered by crhsbandwife on April 15, 2016 at 08:50 AM

    Thanks for getting back to me. Basically I need the submit button to not work if the form is submitted 24 hours or less of the Absence Date and Start Time.

    So yes, Date / STart Time and Date / End time. The date will always be the same.

    A student may miss a rehearsal on September 21st, from 3PM to 5PM, he cannot submit this form any time after 3PM on Septemebr 20th.

    Hope this helps, thank you for your hlep and have a wonderful Friday!

  • Profile Image

    Answered by Ben on April 15, 2016 at 11:01 AM

    Thank you for additional details. It helps us understand what exactly is happening on the form and how to best approach the issue.

    To do this we will need 4 fields:

    1 DateTime field

    1 Time field

    2 Form Calculations

    and next to this just 2 conditions.

    As you can see it will be a very simple thing to do. Now onto it :)

    First we will add a DateTime field and leave it with date only fields, just set it up to always load the current date as its default.

    I have named this field _Now_date.

    Now, we need to add the Time field. I have named it _Now_time and set the current time to be the default just like with date field.

    OK, now we have the fields we need set up to load current time and day. Now we need to do some math and for that form calculation widgets are a great help.

    The first one we will add will tell us how many days the two dates are apart. To do that, we set it up to calculate the same by getting Date of Absence field and subtracting  _Now_date from the same.

    If the dates are 2 or more, we can show submit button as they are more than likely to be over 24 hours away from each other, so there is not much to discus about. As such we turn that into the condition.

    I have named this calculation _Days difference and these are the conditions around the same:

    So what happens if the days difference is 0? That means that it is definitely under 24 hours and per the rule above it will be hidden.

    Now the question comes, what if we have 1 days of difference but are over 24 hours. For that we use the second calculation.

    I have called it _time_difference.

    The calculation that we will use is as follows:

    (24 - _Now_time) + Absence_start_time or basically we calculate how many hours from now we have to today and then add the same hours to the absence hours.

    This is how it looks:

    OK, so now we know if the time is over 24 or under 24. Lets take it by example you have said.

    If it is 3PM and they try to submit the form on 4PM the day before, the math would be as follows:

    (24 - 16) + 15 = 23 - Ups, its under 24 hours and now can not be submitted.

    What if they submit it an hour before at 2PM?

    (24 - 14) + 15 = 25 - Yup, over 24 hours and can be submitted :)

    So what we need to do now, is to simply check if we have over 24 hours if the days difference is 1.

    Now, lets combine this into a nice and simple condition:

    And that is it :)

    You can check out the form here that shows it all how it works and allows you to clone it over for inspection: https://form.jotform.com/61053803075954

    Now, once you inspect it and do your tests, you can simply hide the fields that you do not wish to see by clicking on them and then through the little gear wheel on the top right, you can get to the Hide option:

    That will allow you to keep calculations and hide the fields from others ;)

    Hope this helps, but do let us know if this is what you were after.