I am using piackadate.js as a date picker for my site. I would like to implement the functionality that would disable any previous date. I read the docs on disabling dates but I don't see a way to disable all previous dates.
How would one do this?
the previous dates we need to set the minDate property of the date picker. if we set minDate:0 then it will disable all the previous dates. and we set input attribute min:current_date then it will disable all the previous dates.
You can do it much easier. It will disable all the previous dates.
$('#test').pickadate({
min: true
});
Try this:
var yesterday = new Date((new Date()).valueOf()-1000*60*60*24);
$('#test').pickadate({
disable: [
{ from: [0,0,0], to: yesterday }
]
});
1000*60*60*24
is the number of milliseconds in a day.
Demo: http://jsfiddle.net/alan0xd7/kdoo53vg/
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With