Gravity Forms – Blocking Day on Calendar Field Script
-
Hi,
On my website alegrefarm.com/contact, I’m using Gravity Forms plugin and I needed to block Sunday on one of my fields and inserted the script:
<script>// no sundays
gform.addFilter( ‘gform_datepicker_options_pre_init’, function( optionsObj, formId, fieldId ) {optionsObj.firstDay = 1;
optionsObj.beforeShowDay = function(date) {
var day = date.getDay();
return [(day > 0), ”];
};return optionsObj;
});
</script>It works, but unfortunately, I have two calendar fields and I don’t need to block sunday on both. On the first calendar field, Sunday does not need to be blocked (Field ID 9). Sundays need to be blocked only on the second calendar field (Field ID 25).
Gravity Forms support gave me a link to:
https://gist.github.com/richardW8k/515454542d1111e8c12cand told me to use the “if” statement. I don’t know what that means but they won’t help me any further.
I tried this but it doesn’t work:
<script>// no sundays
gform.addFilter( ‘gform_datepicker_options_pre_init’, function( optionsObj, formId, fieldId ) {
if (formId == 25)
optionsObj.firstDay = 1;
optionsObj.beforeShowDay = function(date) {
var day = date.getDay();
return [(day > 0), ”];
};return optionsObj;
});
</script>Anyone have any idea what this script needs to be in order to achieve my goal of only blocking Sunday on the second calendar field (Field ID 25?) Thank you.
Best Regards,
Kelly
- The topic ‘Gravity Forms – Blocking Day on Calendar Field Script’ is closed to new replies.