# How to disable weekends in Date picker with script?

**URL:** <https://community.gravityforms.com/t/how-to-disable-weekends-in-date-picker-with-script/15088>\
**Category:** Get Help\
**Tags:** has-ticket, datepicker\
**Created:** [May 7, 2023, 6:47pm UTC](https://community.gravityforms.com/t/how-to-disable-weekends-in-date-picker-with-script/15088 "2023-05-07T18:47:34Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![nourmedia](https://avatars.discourse-cdn.com/v4/letter/n/898d66/32.png) [@nourmedia](https://community.gravityforms.com/u/nourmedia)\
**Post date:** [May 7, 2023, 6:47pm UTC](https://community.gravityforms.com/t/how-to-disable-weekends-in-date-picker-with-script/15088/1 "2023-05-07T18:47:34Z")

</div>

How to disable weekends in Date picker with script?

I am using the following script i found in the documentation of Gravity Forms and it used to work. But now it’s not working anymore.

\< script \>  
gform.addFilter( ‘gform\_datepicker\_options\_pre\_init’, function( optionsObj, formId, fieldId ) {  
// Apply to field 66 only  
if ( fieldId == 66 ) {  
optionsObj.minDate = 0;  
optionsObj.firstDay = 1;  
optionsObj.beforeShowDay = jQuery.datepicker.noWeekends;  
}  
return optionsObj;  
});  
\< /script \>

---

<div class="post-metadata">

**Author:** ![chrishajer](https://sea2.discourse-cdn.com/flex020/user_avatar/community.gravityforms.com/chrishajer/32/88_2.png) [@chrishajer](https://community.gravityforms.com/u/chrishajer)\
**Post date:** [May 8, 2023, 4:28am UTC](https://community.gravityforms.com/t/how-to-disable-weekends-in-date-picker-with-script/15088/2 "2023-05-08T04:28:06Z")

</div>

Hi Ibrahim. I replied to your support ticket. If you need assistance, please reply there. Thank you.

---

<div class="post-metadata">

**Author:** ![nourmedia](https://avatars.discourse-cdn.com/v4/letter/n/898d66/32.png) [@nourmedia](https://community.gravityforms.com/u/nourmedia)\
**Post date:** [May 8, 2023, 6:59am UTC](https://community.gravityforms.com/t/how-to-disable-weekends-in-date-picker-with-script/15088/3 "2023-05-08T06:59:22Z")

</div>

Hi Chris,

It worked like a charm. Thank you.

One more question. I presume that at the next update the bug will be fixed. Do i have to put everything back as it was before?

---

<div class="post-metadata">

**Author:** ![chrishajer](https://sea2.discourse-cdn.com/flex020/user_avatar/community.gravityforms.com/chrishajer/32/88_2.png) [@chrishajer](https://community.gravityforms.com/u/chrishajer)\
**Post date:** [May 8, 2023, 8:21pm UTC](https://community.gravityforms.com/t/how-to-disable-weekends-in-date-picker-with-script/15088/4 "2023-05-08T20:21:46Z")

</div>

Hello. No, you won’t need to remove the snippet. But also, the snippet will no longer be necessary. Remove the snippet once you have updated Gravity Forms to the patched release. Thank you.

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/flex020/uploads/gravityforms1/original/2X/f/fef63f0599c45e0218c30d9f5d7ca8bff9b00189.png) [@system](https://community.gravityforms.com/u/system)\
**Post date:** [June 7, 2023, 8:22pm UTC](https://community.gravityforms.com/t/how-to-disable-weekends-in-date-picker-with-script/15088/5 "2023-06-07T20:22:09Z")

</div>

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