Modifier le champ date en fonction de la date et l'heure du jour

  • farah.badat
    Demandé le 10 juin 2022 à 09:06

    Bonjour,

    Je souhaite trouver une solution pour réservation de repas.

    Ainsi dans mon formulaire j'aurai coordonnées du client, mes repas au choix et la date.

    Si le client est sur le formulaire à partir de 10h du matin il ne doit plus pouvoir réserver pour ce jour. Et du coup la date par défaut sera celle du lendemain.


    Est-ce que c'est possible de le faire sur Jotform ?


    merci bien et bonne journée

  • Lucas Support Team Lead
    Répondu le 10 juin 2022 à 19:59

    Hi farah.badat,

    Thanks for reaching out to Jotform Support. I understand you want to change the date to the next day if it's after 10am, right? Please allow me some time to check if I can build a solution for you, and soon I will be back here.

  • Lucas Support Team Lead
    Répondu le 10 juin 2022 à 20:30

    Hi farah.badat,

    Thanks for your patience. I created a workaround for you, I hope it works for you. I cloned your form and built a form that changes the date automatically to the next date in case it's after 10am. You can test my form and clone it if you want on this link.

    Now, let me show you how you can do this:

    • Add to your form the basic elements Date Picker and Time.
    • Hide both elements.
    • Open the properties of Data Picker and Time, navigate to options tab, and set both Default Date and Default time as current.
    • Your original date field should be set with no default date. Your form should look like this at this point:

    1654906510 62a3de8ed35be  Screenshot 10

    • Now it's time to create a condition. Navigate to settings and click on conditions on the left side menu.
    • Add a new condition to update / calculate field.
    • Create the following condition:

    1654906648 62a3df182e376  Screenshot 21

    • To calculate the date, you should use the function dateString() - To use a function, click on the three dots button on the calculator keyboard and search for dateString() - to add a field, click on the add field button.

    This condition is set to after 10 am get the current date and add one day more to it and insert this new date on the date field visible for users on the form.

    Check out this guide to learn a bit more about conditions using date and time. That's it. I hope it works for your case and let us know if you have any other questions.