0

I am trying to create a datepicker using twitter datepicker.css and bootstrap-datepicker.js but it's not working. I'm using codeigniter in this project.

<input type="text" name="end_date" value="" class="datepicker" data-format="dd-MM-yyyy" />  

<script>
    $(function() {
        $( ".datepicker" ).datepicker();
    });
</script>

I've included both the files mentioned above but this is not working. How can I make it work?

I have a Error(Firebug) --> "TypeError: $(...).datepicker is not a function"

4
  • Getting any console errors? Commented Jul 19, 2013 at 17:09
  • 1
    how about a jsfiddle that doesn't work Commented Jul 19, 2013 at 17:09
  • i'm using bootstrap-responsive.css too but not bootstrap.css. Do this creates problem? Commented Jul 19, 2013 at 17:45
  • Error(Firebug) --> "TypeError: $(...).datepicker is not a function" Commented Jul 20, 2013 at 6:23

2 Answers 2

2

You can can use : http://www.eyecon.ro/bootstrap-datepicker/

$(function() {
  $(".datepicker").datepicker({format:'dd/mm/yyyy'});
});

here's a working example : https://refork.codicode.com/x771

Sign up to request clarification or add additional context in comments.

5 Comments

I included datepicker.css & bootstrap-datepicker.js in the head section, form in the body and $(function() after the form. What am I missing?
I included jquery.1.9.1.min and now it's working but when I add it to my project (which has got other js files too), it's not working. Isn't there any way to stop this? Conflicts may have caused it.
Error(Firebug) --> "TypeError: $(...).datepicker is not a function"
the files needed are: (jquery js, bootstrap js, bootstrap-datepicker js). if your js file is causing a conflict or misconfiguration you have to find it.
Also, check the source code of the page, make sure the jquery core is loaded before the datepicker and that the links to the files are valid.
0

red one,

It would be helpful to share a jsFiddle of your code. At least let us know what scripts you are loading and styles you are loading and in which order. Since the datepicker is dependent on jQuery you need to make sure that jQuery is loading before your .js files. You asked about the bootstrap-responsive and bootstrap files. As long as you are linking to the correct one it should work.

Hopefully that gives you a little direction. Will update when you share more information.

2 Comments

I'm using this datepicker.css and bootstrap-datepicker.js
Where are you loading jQuery?

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.