Disable future dates after today in Jquery Ui Datepicker

后端 未结 8 1071
旧巷少年郎
旧巷少年郎 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 });
    

提交回复
热议问题