Reputation: 1110
How to disable past dates from Bootstrap Datepaginator, i want to show pagination from current date and disable the past dates
Upvotes: 0
Views: 348
Reputation: 2525
Try this code :
var today = new Date();
var dd = today.getDate();
var mm = today.getMonth()+1; //January is 0!
var yyyy = today.getFullYear();
if(dd<10){
dd='0'+dd
}
if(mm<10){
mm='0'+mm
}
var today = yyyy+'-'+mm+'-'+dd;
var options = { startDate: today }
$('#paginator').datepaginator(options);
Set current date as the start date
Upvotes: 1
Reputation: 2356
Take a look at the documentation - https://github.com/jonmiles/bootstrap-datepaginator. It looks like you want to use the startDate
option.
var options = {
startDate: '2015-07-30'
}
$('#paginator').datepaginator(options);
The option will either take a string (as in my example), or a moment
object (http://momentjs.com/). I would suggest using moment as it makes working with date objects super easy, and in general is a good addition to any project that works with dates. moment()
would return todays date, so you could re-write the above example as follows;
var options = {
startDate: moment()
}
$('#paginator').datepaginator(options);
Upvotes: 1