• Hi, I have searched for this and have found some answers so I think it can be done but I haven’t been able to figure out how to make it work with my form.

    My form is for booking tours, and there are certain days (i.e. holidays and other exceptions) when people cannot book tours. One of the fields in my form is a “date” type field, and this is the field I would like to be able to disable specific dates for.

    If this is possible, can someone please explain to me how to do it? I found the code below on another site where someone was asking a similar question, and I tried adding this to my form (above where the fields are) but it didn’t work – they can still select the dates that I’ve “disabled” (and yes I made sure to set the date field “id:datedisable”)

    <script type="text/javascript">
    	//set disabled dates here
        var unavailableDates = ["19-7-2013", "20-7-2013", "21-7-2013", "22-7-2013", "23-7-2013", "24-7-2013", "25-7-2013", "26-7-2013", "27-7-2013", "28-7-2013", "29-7-2013", "30-7-2013", "31-7-2013", "22-5-2013", "23-5-2013", "24-5-2013"];
        //disabled dates end here
    	jQuery(function($){
    		$( "#datedisable" ).datepicker({
            	minDate: 5,
            	beforeShowDay: function(date) {
            	dmy = date.getDate() + "-" + (date.getMonth() + 1) + "-" + date.getFullYear();
    			if ($.inArray(dmy, unavailableDates) == -1) {
    				return [true, ""];
    			} else {
    				return [false, "", "Unavailable"];
    			}
    		}
    	});
    });
    </script>

    https://www.ads-software.com/extend/plugins/contact-form-7/

  • The topic ‘How to disable specific dates from a date field?’ is closed to new replies.