0

I have a requirement to disable dates(entire week of Thanks giving day) in date picker control.Its a sharepoint date time control.I am facing error :"$("#control id").datepicker() is not a function" in sharepoint 2013 list New Form.

Checked the jquery library loading once and jquery UI library loading after Jquery library.I am not sure why getting this error on page load.

Below are the code images :where 1st image code disables all the dates excepts dates that comes on "Thursday"[strDay =4] by default.

So My requirement is to disable the week of "Thanks Giving Day" and 2 weeks of "Christmas" day. Hence, below is the 2 image code written on same date picker field where I just need to disable dates (2022/11/24,2022/12/22,"2022/12/29").As ,only these dates are enabled on the calendar.

Please suggest ways to resolve this issue.

3
  • Can you share the code you are using? Where you have added this code, inside document.ready() function or somewhere else? Oct 25, 2022 at 16:12
  • I know you mentioned jQuery library loading once, but can you try using this: var $j = jQuery.noConflict(); $j("#control id").datepicker(); Oct 25, 2022 at 16:15
  • it is on page load only. I tried :var $j = jQuery.noConflict(); $j("#control id").datepicker(); but getting the error still.
    – Swetha
    Nov 4, 2022 at 11:29

1 Answer 1

0

Try to use _spBodyOnLoadFunctionNames:

<script type="text/javascript" src="<path-to-your-jquery.js>"></script>
<script language="javascript" type="text/javascript">
  _spBodyOnLoadFunctionNames.push("BodyOnLoad");
  function BodyOnLoad() {
    // use "jQuery" instead of "#"
    // ... jQuery("#control id").datepicker() ...
  }
</script>

If you are using Script Editor webpart, put this webpart to the very bottom of your page.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.