Reputation: 2478
I'm using bootstrap-datepicker and I need to configure it to allow only selection from current day to end day in the current month, I don't want to allow users to navigate trough months, is that possible? How? I read the docs but doesn't find any really helpful
Upvotes: 1
Views: 2966
Reputation: 56501
1) You can use the startDate
and endDate
options of bootstrap datepicker.
2) Set today's date in startDate
var today = new Date();
3) To get last date of the month use this approach
var lastDate = new Date(today.getFullYear(), today.getMonth() + 1, 0);
Finally
var today = new Date(); //Get today's date
var lastDate = new Date(today.getFullYear(), today.getMonth() + 1, 0); //To get the last date of today's month
$("#datepicker").datepicker({
startDate: today,
endDate: lastDate
});
Upvotes: 3