Disable future dates after today in Jquery Ui Datepicker

后端 未结 8 1041
旧巷少年郎
旧巷少年郎 2020-12-03 10:25

I want to disable all the future dates after today in Jquery Ui Datepicker

Here is the Demo :

Code :

$( \"         


        
相关标签:
8条回答
  • 2020-12-03 10:35

    You can simply do this

    $(function() {
        $( "#datepicker" ).datepicker({  maxDate: new Date });
      });
    

    JSFiddle

    FYI: while checking the documentation, found that it also accepts numeric values too.

    Number: A number of days from today. For example 2 represents two days from today and -1 represents yesterday.

    so 0 represents today. Therefore you can do this too

     $( "#datepicker" ).datepicker({  maxDate: 0 });
    
    0 讨论(0)
  • 2020-12-03 10:41

    Try this

     $(function() {
      $( "#datepicker" ).datepicker({  maxDate: new Date() });
     });
    

    Or you can achieve this using as below:

    $(function() {
      $( "#datepicker" ).datepicker({  maxDate: 0 });
    });
    

    Reference

    DEMO

    UPDATED ANSWER

    0 讨论(0)
提交回复
热议问题