Bootstrap and datepicker
HTML
<script src="http://netdna.bootstrapcdn.com/twitter-bootstrap/2.1.0/js/bootstrap.min.js"></script>
<link rel="stylesheet" href="http://netdna.bootstrapcdn.com/twitter-bootstrap/2.1.0/css/bootstrap.min.css">
<link rel="stylesheet" href="http://eternicode.github.io/bootstrap-datepicker/bootstrap-datepicker/css/datepicker.css">
<script src="http://eternicode.github.io/bootstrap-datepicker/bootstrap-datepicker/js/bootstrap-datepicker.js"></script>
<input type="text" id="date" />
JavaScript
var challenge_start = new Date(2015,02,04);
var challenge_end = new Date(2015,06,12);
function getDatePlusDays(origDate, days) {
var date = new Date(origDate.getTime());
date.setDate(date.getDate() + days);
return date;
}
function getClosestDateInRange(startDate, endDate, date) {
return (date < startDate) ? startDate
: ((date > endDate) ? endDate: date);
}
var today = new Date();
var range_start = getClosestDateInRange(challenge_start, challenge_end, getDatePlusDays(today, -14));
var range_end = getClosestDateInRange(challenge_start, challenge_end, today);
$("#date").datepicker({
startDate: range_start,
endDate: range_end,
keyboardNavigation: false,
autoclose: true,
todayHighlight: true,
//language: langdate,
disableTouchKeyboard: true
});