Hello all I am trying to set the datepicker options minDate, maxDate, and defaultDate from materializecss in javascript. I am using version 1.0.0-rc.1 build. In the documentation it states that the type for these options are Date objects. When I open the picker, the options are not set and in fact (see chrome dev tools screenshot) the options are null or invalid. Any ideas? Thanks
Code:
<script>
var startDateElem = document.getElementById('student_sdate');
var startDateInstance = M.Datepicker.init(startDateElem, {minDate: new Date("<?php echo $projectTuple['sdate']; ?>"),
maxDate: new Date("<?php echo $projectTuple['edate']; ?>"),
defaultDate: new Date("<?php echo $projectTuple['sdate']; ?>"),
onSelect: function(newDate){
endDateInstance.options.minDate = newDate;
}});
var endDateElem = document.getElementById('student_edate');
var endDateInstance = M.Datepicker.init(endDateElem, {minDate: new Date("<?php echo $projectTuple['sdate']; ?>"),
maxDate: new Date("<?php echo $projectTuple['edate']; ?>"),
defaultDate: new Date("<?php echo $projectTuple['edate']; ?>"),
onSelect: function(newDate){
startDateInstance.options.maxDate = newDate;
}});
</script>