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 == 3 && fieldId == 9 ) {
		optionsObj.minDate = '+1 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.

Another solution is to use a plugin like Gravity Wiz.

Submit a Comment

Your email address will not be published.