Is there anyway to allow only weekday selections in the bootstrap date picker found below? https://github.com/eternicode/bootstrap-datepicker/
I'm instantiating the date picker like this:
$('#datepicker').datepicker();
/* Update datepicker plugin so that MM/DD/YYYY format is used. */
$.extend($.fn.datepicker.defaults, {
parse: function (string) {
var matches;
if ((matches = string.match(/^(\d{2,2})\/(\d{2,2})\/(\d{4,4})$/))) {
return new Date(matches[3], matches[1] - 1, matches[2]);
} else {
return null;
}
},
format: function (date) {
var
month = (date.getMonth() + 1).toString(),
dom = date.getDate().toString();
if (month.length === 1) {
month = "0" + month;
}
if (dom.length === 1) {
dom = "0" + dom;
}
return month + "/" + dom + "/" + date.getFullYear();
}
});
Thanks for any help.
The latest version from https://github.com/eternicode/bootstrap-datepicker already has an option to disable selection of particular weekdays. From the docs:
In other words, just instantiate your datepicker like this:
Here's a jsfiddle demonstrating this: http://jsfiddle.net/vj77M/1/
** UPDATE **
Bootstrap datepicker now has a
daysOfWeekDisabled
option. See @fin's answer below.** OLD ANSWER **
Here is a working demo
Assuming your weeks starts on sunday:
If not, just change $days.eq(...) to the correct indices.
Of course, this only covers the click event and gets you headed in the right direction. I'm quite sure other things like keyboard navigation may need to be addressed.
EDIT
For latest version use this code where appropiate
also you can try it.
hope it helps someone. :)