mymth / vanillajs-datepicker

A vanilla JavaScript remake of bootstrap-datepicker for Bulma and other CSS frameworks
MIT License
752 stars 155 forks source link

limit start date to today #18

Closed greatgraphicdesign closed 4 years ago

greatgraphicdesign commented 4 years ago

It would be really nice to be able to limit the start date so it can't be older than today. Thank you!

DRocksCoding commented 4 years ago

I think you can set minimum date to today in the instance options when you instantiate your Datepicker.

greatgraphicdesign commented 4 years ago

I would love to find it; however, I'm not seeing it in the docs.

DRocksCoding commented 4 years ago

Look at this file it's the complete default options object and you will see minDate and maxDate : https://github.com/mymth/vanillajs-datepicker/blob/master/js/options/defaultOptions.js

I was able to use it by setting a minDate parameter when I instantiate my Datepicker. You'll need to set the minDate with the current date format you are passing to the Datepicker.

greatgraphicdesign commented 4 years ago

I somehow missed minDate. Thank you so much for following up.

I added the following option, and it works! minDate: new Date().toLocaleDateString("en-US")

mymth commented 4 years ago

@greatgraphicdesign You can use Date object too. So, minDate: new Date() is enough to make it work. (no need to stringify) Just FYI.

greatgraphicdesign commented 4 years ago

Very cool. Thank you!

ravenwits commented 3 years ago

@greatgraphicdesign You can use Date object too. So, minDate: new Date() is enough to make it work. (no need to stringify) Just FYI.

I am currently having the same issue. Actually I've done the same thing minDate: new Date() but it still works like "maxDate" option and it disables all the dates beginning from today and all the past dates are still remains active.