Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Disable Previous Dates When Using Pickadate.js

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?

like image 775
L84 Avatar asked Jul 10 '15 01:07

L84


People also ask

How to disable the previous dates in Datepicker?

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.


2 Answers

You can do it much easier. It will disable all the previous dates.

$('#test').pickadate({
    min: true
});
like image 78
NXT Avatar answered Sep 19 '22 20:09

NXT


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/

like image 29
alan0xd7 Avatar answered Sep 19 '22 20:09

alan0xd7