Datepicker min and max date?

TimTim asked 5 months ago

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!


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 commented 5 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!


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 commented 5 months ago

Thanks so much!


Please insert min. 20 characters.
Status

Resolved

Specification of the issue
  • User: Pro
  • Premium support: No
  • Technology: jQuery
  • MDB Version: -
  • Device: -
  • Browser: -
  • OS: -
  • Provided sample code: No
  • Provided link: No