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

    How can I disable an option based on date condition?

    Asked by tbawa on August 26, 2016 at 11:31 AM

    We have a form that allows booking for a selection of training courses. Booking for a course close 7 days before the course date. Is there a way to disable an option in an option field based on a date condition.

    Page URL:
    https://form.jotform.co/51911563248860

    date condition how based on date how can i
  • Profile Image
    JotForm Support

    Answered by Welvin on August 26, 2016 at 12:34 PM

    Unfortunately, it's not possible to disable an option from a field by a condition. You will have to manually remove the option or do the following workaround:

    1. Separate the options into multiple fields.

    2. Add DateTime field in the form with default date.

    3. Add a conditional logic in the form to hide the fields based on a date. 

     

    https://www.jotform.com/help/316-How-to-Show-or-Hide-Fields-Base-on-User-s-Answer 

  • Profile Image

    Answered by tbawa on August 31, 2016 at 10:57 AM

    Hi Welvin,

    I understand that there is not out-of-the-box solution. Would you have any tips how I could go about finding a Javascript based solution. Sort of along the lines: Use jQuery to find all the relevant radio button elements, extract the date from the value attribute (first 10 characters) of each element. If date < current date + 7 days set the element to disabled.

    I did play around a bit but could get anything going. Probably the because the form is drawn somehow delayed and the elements are not there when my Javascript runs. Just some pointers would be good as I can sort out the finer details myself.

    Thanks

  • Profile Image
    JotForm Support

    Answered by Welvin on August 31, 2016 at 12:29 PM

    Sure, I'll look at it and let you know of the Javascript workaround. But this would need you to get the source codes and embed it as it is after adding the script(s). 

  • Profile Image

    Answered by tbawa on August 31, 2016 at 06:03 PM

    Getting the source and embedding it is fine, I expected that - thanks