0

I am using this code from here:

http://jqueryui.com/datepicker/

I put this code on my website:

<script type="text/javascript">
    $(function() {
     $( "#datepicker" ).datepicker();
     $( "#datepicker2" ).datepicker();
     $( "#datepicker3" ).datepicker();
     $( "#datepicker4" ).datepicker();
  });
</script>

In the Firefox firebug console, I see this error:

 TypeError: $(...).datepicker is not a function
 $( "#datepicker" ).datepicker();

the #datepicker pulls the field tag into it. Why does it say that datepicker() is not a function? if I have the rest of the code above it:

<link rel="stylesheet" type="text/css" href="/css/dateTimepicker/jquery.datetimepicker.css"/>
<script src="/css/dateTimepicker/jquery.js"></script>
<script src="/css/dateTimepicker/jquery.datetimepicker.js"></script>
<style type="text/css">
    .custom-date-style {    background-color: red !important; }
</style>

I have put that code above it and below it and it does not matter. That error is always there.

Can you tell me how to fix it?

Also, I do use other scripts that pull in jQuery, and have a jquery.js file.

Could they be causing a conflict?

Thanks, Richard

5
  • 2
    First of all, you missed }); at the end of script. Secondly, are you sure that /css/dateTimepicker/jquery.datetimepicker.js is correct way (why JS file is in CSS directory and why it is "datetimepicker.js", not "datepicker.js")? Commented Oct 20, 2014 at 9:22
  • I just uploaded it into the css folder on my site. I know that is not where I should put js files, but I just uploaded the whole thing in to there. The datetimepicker.js is from the example I found on that website. and that is the file I uploaded to. I did not change it to that. Commented Oct 20, 2014 at 9:34
  • Yes, the script tags are there, opening and closing. Commented Oct 20, 2014 at 15:24
  • hmm, okay, I'm not a jQuery guru guy, what is jQuery UI? my bad, I don't know. Commented Oct 20, 2014 at 15:54
  • It's not about jQuery guru, it's about including additional script. Add <script src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.10.3/jquery-ui.min.js"></script> between jQuery and datepicker scripts. Commented Oct 20, 2014 at 16:05

1 Answer 1

3

You missing curly braces:

<script type="text/javascript">
  $(function() {
    $("#datepicker").datepicker();
  });
</script>
Sign up to request clarification or add additional context in comments.

1 Comment

My bad, I only copied it from the error... I edited it to have the whole section in my source code:

Your Answer

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

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.