question

AppDev-1530 avatar image
0 Votes"
AppDev-1530 asked YijingSun-MSFT answered

Uncaught TypeError: $(...).datepicker is not a function

Hi All,

Getting the following errors for trying get a datetime picker.

Create:247 Uncaught TypeError: $(...).datepicker is not a function
at Create:247
(anonymous) @ Create:247
Create:243 Uncaught TypeError: $(...).datepicker is not a function
at HTMLDocument.<anonymous> (Create:243)
at o (jquery-1.7.2.min.js:2)
at Object.fireWith (jquery-1.7.2.min.js:2)
at Function.ready (jquery-1.7.2.min.js:2)
at HTMLDocument.B (jquery-1.7.2.min.js:2)

dotnet-aspnet-general
· 9
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

Why are we getting permission errors when typing to post questions?
Can we no longer add source codes???

0 Votes 0 ·

Going to try again can seems to post source codes
Just trying to get a blasted date picker to work

This is the scripting:
$('#z').datepicker({
inline: true,
altField: '#d'
});

     $('#d').change(function () {
         $('#z').datepicker('setDate', $(this).val());
     });

This is the razor for the mvc
<input type="text" id="d" />
<div id="z"></div>


0 Votes 0 ·

Hi @AppDev-1530 , welcome to Microsoft Q&A forum. Is the specific js reference added and loaded without any error? Are you using ASP .NET MVC or ASP .NET Core MVC?

0 Votes 0 ·

Hi I am using ASP .NET MVC,

I read that If I have multiple version of jquery that will cause the problem but I don't know what that means or even how to tell.
Full transparency here, I don't understand jquery all that well at all. I have tried tutorials and it is just mind scrambling to me.

The site will not let me post my source codes. as it says it's too many characters.. this is crazy

0 Votes 0 ·
Show more comments

1 Answer

YijingSun-MSFT avatar image
0 Votes"
YijingSun-MSFT answered

Hi @AppDev-1530 ,
According to your codes,you must add datepicker.js.You need to do like this:

 <s cript src="~/Scripts/jquery-1.12.4.min.js"></s cript>
 <s cript>
     $(function () {
         $('#d').change(function () {
             $('#z').datepicker('setDate', $(this).val());
         });
     })
 </script>
 <h2>Index</h2>
 <input type="text" id="d" />
 <div id="z"></div>
    
 @section scripts
 {
     @Scripts.Render("~/Scripts/jquery-1.12.4.min.js")
     @Scripts.Render("~/Scripts/bootstrap.min.js")
     @Scripts.Render("~/Scripts/bootstrap-datepicker.min.js")
     @Styles.Render("~/Content/bootstrap.min.css")
     @Styles.Render("~/Content/bootstrap-datepicker.min.css")
 }

By the way,if you need to post any codes,you could put codes into txt or screenshots to us.
Best regards,
Yijing Sun


If the answer is helpful, please click "Accept Answer" and upvote it.

Note: Please follow the steps in our  documentation  to enable e-mail notifications if you want to receive the related email notification for this thread.

5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.