Restricting dates in gravity forms calendar

Query regarding adding logic to date (calender) field in gravity forms.

I want to disable past days, weekends and only enable today’s date +3 days (excluding weekends). This is what i have come up with-

<script type="text/javascript">
gform.addFilter( 'gform_datepicker_options_pre_init', function( optionsObj, formId, fieldId ) {
    if ( formId == 16 && fieldId == 1 ) {
        optionsObj.firstDay = 1;
        optionsObj.beforeShowDay = jQuery.datepicker.noWeekends;
optionsObj.minDate = 0;
        optionsObj.maxDate = '+3 D';
    return optionsObj;

The only issue as you can see in the screenshot also- the next 3 weekdays days are not active. It is counting weekends too. Ideally, the active dates should be 22nd, 23rd, 24th and 27th. How do I make changes here? any suggestions. Thanks in advance!

Hi Nandita,

If you’re interested in a much simpler way to get this done, you can check out our GP Limit Dates Perks. A Limit Dates setup as seen below should get the Date field working as you want.



I hope this helps.



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