Restricting Days in Gravity Forms Datepicker

How can I restrict dates in date picker, to force a choice between 3 and 30 days?

Assuming your form ID is 1 and your date field ID is 4, add an HTML field in the form with this script:

<script type="text/javascript">
gform.addFilter( 'gform_datepicker_options_pre_init', function( optionsObj, formId, fieldId ) {
if ( formId == 1 && fieldId == 4 ) {
optionsObj.minDate = '+3 D';
optionsObj.maxDate = '+30 D';
optionsObj.beforeShowDay = function(date) {
var day = date.getDay();
return [day != 0,''];
}
}
return optionsObj;
} );
</script>

More infos about ACF date field.

Submit a Comment

Your email address will not be published.