Search code examples
datepickermaterialize

Disable Future Date in Datepicker of Materialize frame work


Here I am Using Date Picker of materialize frame work. Can anyone Please tell me how can i Disable Future Date from Current Date?


Solution

  • With 1.0 alpha version you can do you can specify maxDate in the options field when initializing the datepicker:

    var elem = document.querySelector('.datepicker');
    var instance = M.Datepicker.init(elem, {
        maxDate: new Date()
    });
    
    // Or with jQuery
    
    $(document).ready(function(){
      $('.datepicker').datepicker({
        maxDate: new Date(),
      });
    });
    

    The other version v0.100.2 does not seem to have the maxDate option.