user2701687 user2701687 - 3 months ago 12x
Javascript Question

How to use bootstrap datepicker

Okay, So I'm new to using frameworks and js libraries and I'm wanting to us bootstrap and bootstrap datepicker for a form and I have no clue if I have the file order correct but the links is how the files are setup, and I know very little about javascript, pretty much all I code in is php but I need this for a form.

Here's my testing form for the bootstrap datepicker:

<!DOCTYPE html>
<meta charset="utf-8">

<link rel="stylesheet" href="_css/datepicker.css">
<link rel="stylesheet" href="_css/bootstrap.css">
<link rel="stylesheet" href="_css/bootstrap-responsive.css">
<script type="text/javascript" src="datepicker/bootstrap-datepicker.js"></script>
<h1>BootStrap Datepicker</h1>
<div class="well span12 main">
<input type="text" id="dp1" class="span2 datepicker" placeholder="Date..."
name="date"> <br>
<input type="submit" value="Search" class="btn">

<!-- JAVAscript ----------------------------------------------------------------->
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="_js/bootstrap-datepicker.js"></script>
<script type="text/javascript" src="_js/bootstrap.js"></script>

What exactly am I doing wrong?


You should include bootstrap-datepicker.js after bootstrap.js and you should bind the datepicker to your control.

      format: 'mm-dd-yyyy'