Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Twitter Bootstrap date picker

How can I use the Twitter Bootstrap date picker? I used the code below but its not working.

<html>     <head>     <title>DatePicker Demo</title>     <script src="js/jquery-1.7.1.js"></script>     <link href="css/datepicker.less" rel="stylesheet" type="text/css" />     <link href="css/bootstrap.css" rel="stylesheet" type="text/css" />     <link href="css/bootstrap.min.css" rel="stylesheet" type="text/css" />     <script src="js/bootstrap-datepicker.js"></script>      </script>     </head>     <body>     <form >         <div class="input">             <input class="small" type="text" value="01/05/2011" data-datepicker="datepicker">         </div>     </form>      </body> </html> 
like image 639
Sangram Anand Avatar asked Nov 25 '11 10:11

Sangram Anand


People also ask

Why my bootstrap datepicker is not working?

Because you're defining the code in the head the body and its contents haven't been loaded yet; so the selector finds no elements to initialize datepicker. If you don't want to use document. ready functionality you could also move the script to the end of the body tag.

How do you use a date picker?

Date pickers look like text boxes, except that a small calendar icon appears on the right side of the box. To open the pop-up calendar, users click the calendar icon. When the calendar appears, users can click the date that they want on the calendar or use the right and left arrow buttons to scroll through the months.


1 Answers

The most popular bootstrap date picker is currently: https://github.com/eternicode/bootstrap-datepicker (thanks to @dentarg for digging it up)

A simple instantiation only requires:

HTML

<input class="datepicker"> 

Javascript

$('.datepicker').datepicker(); 

See a simple example here https://jsfiddle.net/k6qsm5no/1/ or the full docs here http://bootstrap-datepicker.readthedocs.org/en/latest/

like image 77
Josh Stuart Avatar answered Sep 23 '22 13:09

Josh Stuart