Datepicker: Minimum of 2 days excluding weekends

Does anyone know how to add a filter in the datepicker so the user can only choose a date starting 2 days in the future EXCLUDING the weekends.

So if today is Thursday, the next available date is Monday.
I have used this code:

 gform.addFilter( 'gform_datepicker_options_pre_init', function( optionsObj, formId, fieldId ) {
 if ( formId == 1 && fieldId == 29 ) {
 optionsObj.minDate = '+2';
} 
return optionsObj;
});

</script>

…but it doesn’t exclude the weekends in it’s calculation, even though, I’ve also used the following code that doesn’t allow the users to choose a weekend date (and it worked just fine for that purpose):

gform.addFilter( 'gform_datepicker_options_pre_init', function( optionsObj, formId, fieldId ) {
    if ( formId == 1 && fieldId == 29 ) {
      
        optionsObj.beforeShowDay = jQuery.datepicker.noWeekends; 
    }
    return optionsObj;
});

Any ideas, someone?

Hi Mario,

This should be possible with our GP Limit Dates Perk and a snippet we already have. With this, you wouldn’t have to write any custom codes and it would work perfectly for what you want to do.

If you’re interested in a solution without having to write any codes, you may want to check out our GP Limit Dates Perk. Let us know if you have any questions here.

1 Like

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.