Disable form based on specific time

  • doctorsheps
    Asked on November 20, 2022 at 10:12 PM

    I want to create an on call system where patients can request an appointment. Since it is an afterhours service we want to allow them access to the form only between specified hours so they can only enter into the system between certain hours

    for example mon- friday they can enter in between 3 and 9 pm

    saturday 7-3pm

    sunday 7am-12pm

    any other hours or holidays we need to send them an error reply

    so we need a lookup on a database if we are open at that time and return either true or false if the time they are accessing the system is between the opening time and closing time for that date()

    is this possible

    fs

    in a c based logic

    timer=time()

    dater=date()

    use opendates

    seek dater

    opentime=opendates->time1

    closetime=opendates->time2

    if between(timer,opentime,closetime)

    return openform()

    else

    return errormessage

    endif


  • Lorelie JotForm Support
    Replied on November 21, 2022 at 2:38 AM

    Hello Doctorsheps,

    Thank you for reaching out to Jotform Support. You can use an Appointment field element and set the intervals as shown in the screenshot below:

    1669014988 637b25ccda0e2 637b25ccda0a2 Screenshot 10

    You can also block out the dates for holidays so that appointments can't be scheduled on those dates. Then enable it to a required field to prevent submission if the filled is empty. For your error message, I would suggest using the form warnings. You can edit the text in the form of warnings to show your preferred error message.

    1669015955 637b299324ae4 637b299324aa4 Screenshot 21

    Please check it out and let us know if this fits your requirements. If that’s not exactly what you’re looking for, can you explain a bit more so I can help you better?

  • doctorsheps
    Replied on November 22, 2022 at 11:50 PM
    unfortunately not
    We need to control when people are allowed to access the form not when they
    can book once they access the form
    and I dont need them to be able to book a specific time so not really a
    calendar just a request for service
    essentially you can only send me an email or update my database at certain
    times
    If you look at the code I sent it is conditional - we only open the access
    to request an appointment
    between certain times but we do not limit the number of people who can
    access during those times
    hope I did a better job making myself clear
    franklin
    ...
  • Lorelie JotForm Support
    Replied on November 23, 2022 at 1:49 AM

    Hello Franklin,

    Thanks for getting back to us. Unfortunately, it is not possible to look up data from your database, you can set a condition and manually specify the said time when the form will be disabled. Please check out our guide about: Enable or Disable a Form Based on Time Using Conditions. and see if it fits your requirements.

    Give it a try and let us know if you need any other help.

  • doctorsheps
    Replied on November 24, 2022 at 10:50 PM
    this is a great solution if the answer does not change according to the day
    of the week
    in our case it changes depending on day of the week and holidays
    you have conditional forms I gather
    do you have a day of the week function and an inlist function that can be
    used with conditional forms
    so I do not have to use a database
    if dayofweek(date())=monday then hours of operation are between 5-8
    and the inlist function
    if date()={01/10/2022} (its thanksgiving we are closed )
    this allows for intelligence to know if the form can be opened at this time
    fs
    so I could set up conditional logic that would use
    these fields
    Will be a second harriett
    if
    ...
  • Rahul JotForm Support
    Replied on November 24, 2022 at 11:01 PM

    Hi Franklin,

    Thanks for getting back to us with the additional information about your requirements. I understand that you would like to disable the form based on specific time instead of the day of the week. I'll need a bit of time to look into this and will get back to you as soon as I can.

  • Rahul JotForm Support
    Replied on November 25, 2022 at 3:14 AM

    Hi Franklin,

    Thanks for waiting patiently. Unfortunately, no way to disable the form based on different conditions as you have. We can only set a fix date or submissions to disable a form and to display an error message. Below are the available options to disable a form currently:

    1669362167 638071f795db5 638071f795d78 Screenshot 10

    However, you can try setting up conditions based on Time and Appointment field on the form to see if this meets your requirements. Let me walk you through the steps:

    • In the Form Builder, click on Add Form Elements from the top left corner.
    • In the Basic tab, search for Time, drag it to the form, and set it to display current time. I have set it to display on form for testing purpose, but you can hide it using conditions.

    1669363066 6380757a1478a 6380757a1474d Screenshot 21

    • Add an Appointment field from the Basic tab of Form Element window. Setup the Appointment field as per your schedule. See the screenshot below the schedule for Mon -Fri.

    1669362829 6380748d81be5 6380748d81ba8 Screenshot 32

    • Add a Paragraph element from the Form Element window and setup the message you would like to display and hide it by default in the form.

    1669363349 63807695e74fb 63807695e74bf Screenshot 43

    Now setup conditions to display message and hide other fields in the form. Let me show you how:

    • Click on Settings from the top bar.
    • Click Conditions from left panel.
    • Click on Add a new condition and select SHOW / HIDE FIELD.
    • Setup the condition as shown below:

    1669363609 63807799a3eff 63807799a3ec1 Screenshot 54

    1669363644 638077bc3ed31 638077bc3ecf3 Screenshot 65

    • Make sure to click Save.

    Now repeat the above steps i.e. add an Appointment field, Paragraph field to display message for Sat and Sun separately.

    Additionally, you could clone my test form (https://form.jotform.com/223279262602959) to see the conditions and to do more tests on it.

    Let us know if you have any other questions.

  • doctorsheps
    Replied on November 30, 2022 at 4:25 PM
    I am both a doctor and an old time computer software designer
    So I know how to write this is foxpro for all of the good that does me
    Its very frustrating to see the answer so clearly but have no idea how to
    proceed
    we are an on call service for family doctors and only allow same day
    registering
    basically we are open weekdays from 5-8 but want to allow patients to
    register from 3-8
    we are open weekends saturday from 9 -3 and sunday 9-12 but open
    registration at 7
    we are closed on holidays
    I can see 2 solutions
    we could write a script that sits in front of your program and controls
    entry
    I am not sure how or what language etc
    or you have this functionality as described below
    in an ideal world we would have a database and the form logic would do a
    lookup to see the hours for that day
    I gather that does not exist
    but I can do a hard code instead with the holidays and logic with the
    normal hours and avoid the database
    but it would require some functions such as
    day of the week ( date() ) returns monday through sunday
    and date() todays date
    and inlist() is todays date on a list of dates
    so I could ask the question(s)
    if todays date is on a list of holidays inlist ( date(), 01/01/2023 ....)
    send the error message
    else
    continue to next conditional statement
    endif
    do case
    case the day of the week ( of todays date ) is a Monday through thursday
    look at the present time
    if the present time is between (3-9)
    open the form
    else
    send error message
    endif
    case the day of the week is a saturday
    ... more code
    case day of the week is a sunday
    ... more code
    endcase
    I hope that makes sense about what we are trying to achieve
    franklin
    ...
  • Mary JotForm Support
    Replied on December 1, 2022 at 6:55 AM

    Hi Franklin,

    I'm afraid it is not possible to add a database of the holidays and show an error message when the selected date in the appointment field is a holiday. A workaround would be what my colleague has shown above or adding conditions such as the one below:

    1669895713 6388962197c61 6388962197c24 Screenshot 10

    Let us know if you have any other questions.