Search code examples
javascriptjquerywordpressgravityforms

Gravity form datepicker customization


I want to customize the gravity form date picker and have added javascript code to do so.

gform.addFilter('gform_datepicker_options_pre_init', function(optionsObj, formId, fieldId) {
  if (formId == 4 && fieldId == 9) {
    optionsObj.firstDay = 1;
    optionsObj.beforeShowDay = function(date) {
      var day = date.getDay();
      return [(day == 0 || day == 6)];
    };
  }
  return optionsObj;
});

It was copied from their documentation website, but this code does not seem to have any effect. Can anyone let me know if I need to do anything else?

My page url: https://youraustinstorage.com/test/


Solution

  • just found the solution.

    I am using Autoptimise plugin and had to enable this option

    "Also aggregate inline JS?
    Let Autoptimize also extract JS from the HTML. Warning: this can make Autoptimize's cache size grow quickly, so only enable this if you know what you're doing."

    to make my inline gravity form javascript work fine