• Hi, I’m wondering if there’s any way to disable specific dates (either individually or via a range of dates) from within a datepicker field in a ContactForm7 form? I’m not sure if this functionality is already available within the plugin (if so, what is the correct syntax?) or if I would need a special script or other plugin in order to be able to do this…but any help would be greatly appreciated!

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

Viewing 1 replies (of 1 total)
  • Thread Starter iconoclastix

    (@iconoclastix)

    I found this code:

    <script type="text/javascript">
    	var unavailableDates = ["1-9-2013", "2-9-2013", "3-9-2013", "4-9-2013", "5-9-2013"];
    
    	function unavailable(date) {
    			dmy = date.getDate() + "-" + (date.getMonth() + 1) + "-" + date.getFullYear();
    			if (jQuery.inArray(dmy, unavailableDates) == -1) {
    				return [true, ""];
    			} else {
    				return [false, "", "Unavailable"];
    		}
    	}
    
    		jQuery(function() {
    			jQuery( '#dpick' ).datepicker({
    				dateFormat: 'dd MM yy',
    				beforeShowDay: unavailable
    		});
    
    	});
    </script>

    and it seems to work fine in jsfiddle, but it won’t work when I put it on my site. I added it in the header.php file just below the wp_head() call and just above the </head> tag (so it’s after the JS/jQuery libraries)…I’ve set it to match the id on my datepicker field, but I’m still getting a JS error in console…can anyone help me out? Seems like it should be easy to get it working but I’m probably just missing some small formatting thing…

Viewing 1 replies (of 1 total)
  • The topic ‘Disable/block specific dates from datepicker?’ is closed to new replies.