Datepicker min and max date?

MDB SupportCategory: MDB jQueryDatepicker min and max date?
TimTim Pro UserPremium asked 3 months ago in MDB pro, version:4.5.0

Hi. how to set the max date, different for each field (with different IDs)!

id=”date1″, id=”date2″, id=”date3″….

And, how to change the max date without reloading the page.

Thank!

2 Answers
Mikołaj Smoleński answered 3 months ago

Hi Tim,

I’ve prepared a code for You, which is solving Your issue with different datepicker fields:

<div class="md-form">
 <input placeholder="Selected date" type="text" id="date-picker-example" class="form-control datepicker">
 <label for="date-picker-example">Try me...</label>
</div>
<div class="md-form">
 <input placeholder="Selected date" type="text" id="date-picker-example2" class="form-control datepicker2">
 <label for="date-picker-example">Try me...</label>
</div>

Regards

TimTim Pro User replied 3 months ago

You misunderstood me!
I do so. $ ('#date1'). pickadate ({
max: new Date (2018,5,14)
});
This only works when the page loads. After assembling the page, this property does not change.
How do I rebuild (change this property) without reloading the page?
Thank you!

Mikołaj Smoleński answered 3 months ago

Hi Tim,

Sorry for the misunderstanding. I prepared another example that shows how to reload datepicker without refreshing the page:

<div class="md-form">
 <input placeholder="Selected date" type="text" id="date-picker-example" class="form-control datepicker">
 <label for="date-picker-example">Try me...</label>
</div>
<button class="btn btn-primary change-date">Change max date</button>
$('.datepicker').pickadate();
var picker = $('.datepicker').pickadate('picker');
picker.set('max', new Date(2018,4,14));
$('.change-date').on('click', function() {
 picker.set('max', new Date(2018,4,25));
})

Regards

TimTim Pro User replied 3 months ago

Thanks so much!