Gravity Forms restricting days in the date picker

This short tutorial is for Gravity Forms users, specifically those willing to get involved in a little code!

WordPress Tech

This short tutorial is for Gravity Forms users. We use this plugin extensively for our project work.

When working with the Gravity Forms date picker you sometimes have to get fancy with eliminating days so that a user can not choose them.

In this situation we needed to disable Saturdays, why would you want to do anything on a Saturday?

The Gravity Forms Date Picker is using jQuery so you can interact with it as the page loads.

This kind of script belongs in a script tag, could be in your Javascript files that are included in your page load, or perhaps if you’re using Genesis as your framework you can put this in the scripts field that allows this on a page by page basis.

As you can see in the screenshot, Saturday; they are no longer an option.


Gravity Forms Date Picker
function noSaturdays(date) {
	var weekday=new Array(7);
	if(weekday[date.getDay()] == 'Saturday') {
		return [false, '', 'Not available Saturdays'];
        }else if(weekday[date.getDay()] == 'Saturday') {
                 return [false, '', 'Not available Saturdays'];

	return [true];
	jQuery('.hasDatepicker').datepicker('option', 'beforeShowDay', noSaturdays);

Reader Interactions


  1. Mr. Hinz says

    Hi Peter, thanks for your code-snippet. Why do we need the if and else-if? :

    if (weekday[date.getDay()] == ‘Saturday’) {
    return [false, ”, ‘Not available Saturdays’];
    } else if(weekday[date.getDay()] == ‘Saturday’) {
    return [false, ”, ‘Not available Saturdays’];

    Both have the same condition:
    weekday[date.getDay()] == ‘Saturday’

    Thanks in advance.

Leave a Reply

Your email address will not be published. Required fields are marked *