How to set minDate to current date in jQuery UI Datepicker?

前端 未结 7 960
渐次进展
渐次进展 2020-12-03 04:26

This is my code and it is not working correctly. I want to set minDate to the current date. How can I do it?

$(\"input.DateFrom\").datepicker({
         


        
7条回答
  •  萌比男神i
    2020-12-03 04:39

    You can use the minDate property, like this:

    $("input.DateFrom").datepicker({
        changeMonth: true, 
        changeYear: true, 
        dateFormat: 'yy-mm-dd',
        minDate: 0, // 0 days offset = today
        maxDate: 'today',
        onSelect: function(dateText) {
            $sD = new Date(dateText);
            $("input#DateTo").datepicker('option', 'minDate', min);
        }
    });
    

    You can also specify a date, like this:

    minDate: new Date(), // = today
    

提交回复
热议问题