Date Picker > Limits: Set limits based on the day the form is filled

  • Profile Image
    nelsonaponte
    Asked on April 14, 2017 at 05:40 AM

    We need something similar, although a little bit more detailed.

    If we can limit for example "today + 1business_day".

    For example, if the current day is Thursday, the people who fill out the form won't be able to select Thursday, Friday, Saturday or Sunday (but they will be able to select every day of the following weeks, including Satudays and Sundays).

    If the current day is Friday, they won't be able to select Friday, Saturday, Sunday or Monday, but they will be able to select any date after that (including Saturdays and Sundays).

    If the current day is Saturday or Sunday, they won't be able to select Saturday, Sunday or Monday, but they will be able to select any date after that (including Saturdays and Sundays).

    If the current day is Monday, they won't be able to select Monday or Tuesday, but they will be able to select any date after that (including Saturdays and Sundays).

  • Profile Image
    ashwin_d
    Answered on April 14, 2017 at 07:47 AM

    Hello nelsonaponte,

    Please note that our date limits feature cannot hide conditional dates.

    I believe it is possible to achieve your requirement by taking advantage of our "Conditions" feature but not from date Picket limits. You can add condition in your form to check today's day and based on that calculate which dates should not be allowed. If the condition matches, you can show an error message in text field and hide the submit button.

    Do get back to us if such workaround will fit into your requirement and we will be happy to create a demo form for you.

    We will wait for your response.

    Thank you!

  • Profile Image
    nelsonaponte
    Answered on April 14, 2017 at 10:04 AM

    Hi Ashwin, thanks for your prompt response.

    Please do let me know how can I set it up with conditions.

     

    Regards

  • Profile Image
    Kevin_G
    Answered on April 14, 2017 at 12:03 PM

    I've made a sample form to show you how this could work with conditions, I've taken the Friday example to apply it to my testing form, here are the steps to apply it: 

    1. Add two date fields to your form, one that will capture the current date and a second one where you will capture the user's entered date:

    2. Then you will need to add two Form Calculation widgets that will help you to know the selected date and another where you will calculated the difference between both dates: 

    3. You will also need to add the text field where you will show the message informing your user the selected date is not valid: 

    4. Now, to set the current date you only need to click on the field, gear icon, options tab and select current as default date: 

    5. The next step is to get the string of the current date, this will help you to know the selected day, to achieve it you will need to use math functions in the form calculation widget, I used the dateString() function, you will also find more details about it here: https://www.jotform.com/help/267-Form-Calculation-Math-Function-Reference 

    6. In the form calculation widget where you will capture the number of days you only need to add the following mathematical operation: 

    How will the number of days help to achieve this?

    Basically, you need to limit your users to select a date with certain difference between the current date, for example, on this statement: 

    "If the current day is Friday, they won't be able to select Friday, Saturday, Sunday or Monday,"

    User would have to select Tuesday, so the date should be 4 days after the current date (the same happens with all your statements) and performing the calculation will help you to know the number of days between both dates so you can set up your calculations, the result in the calculation would be this, taking into account that we're working on the Friday example: 

    A) If selected date is Friday, the difference of days will be 0. 

    B) If selected date is Saturday, the difference of days will be 1. 

    C) If selected date is Sunday, the difference of days will be 2. 

    D) If select date is Monday, the difference of days will be 3.

    This logic should also be applied to the other statements you need on your form. 

    7. The final step is to set up the condition that will show the text alert, here's a screenshot about how this can be set up:

    On the statement where you evaluate the number of days between both dates, it should be four, taking into account that if user selects the current date the calculation result will be 0, you need to set it to be less than 4 since this value will be allowed which means the selected date is correct.

    Here's the link to my sample form where you can see how this works: https://form.jotformpro.com/71034411150943

    Feel free to clone it - How-to-Clone-an-Existing-Form-from-a-URL

    Please, if you have any question, let us know.