Note that there are some explanatory texts on larger screens.

plurals
  1. POJS/jQuery TypeError: jQuery(...).datepicker is not a function
    text
    copied!<p>I've been scratching my head on this for 2 days, pretty sure I'm just missing something simple but I can't for the life of me figure out why it's not working.</p> <p>I'm trying to use the script below on my WordPress site to disable specific dates within a datepicker field in a ContactForm7 form.</p> <p>I can load the script in jsfiddle with a simple input field using the same id and it works perfectly...but when I add it to my site the dates aren't disabled, and there's an error in the JS error console that says "jQuery(...).datepicker is not a function"</p> <p>I've added it in my <code>header.php</code> file, just below the <code>wp_head()</code> call and just above the <code>&lt;/head&gt;</code> tag. I've assigned my datepicker field with the id of <code>dpick</code> like the script uses.</p> <p>I read that this error is commonly caused when using the <code>$</code> symbol because it can conflict with other jQuery scripts within WordPress...so they suggested replacing <code>$</code> with <code>jQuery</code> instead (which I've done in the script below)...but I'm still getting the error</p> <pre><code>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 }); }); </code></pre> <p>Can't thank you enough for any help you can offer...this seems like such a simple thing but I just can't seem to wrap my head around it!</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload