How can I disable an option based on date condition?

  • Profile Image
    tbawa
    Asked 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.

  • Profile Image
    Welvin
    Answered 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
    tbawa
    Answered 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
    Welvin
    Answered 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
    tbawa
    Answered on August 31, 2016 at 06:03 PM

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