Disable dates older than today in the DatePicker plugin

Im using the DatePicker plugin for the project. But I want to disable dates older than today (the user could not select the old dates) My js:

datePickerController.createDatePicker({
formElements:{"inp1":"d-ds-m-ds-Y"} });

In the manual: Both methods accept an Object that represents the dates or date ranges to disable. I could not turn off the old days, but with a lot of trial and error. Could you show me how to do this? thanks in advance

Edit:

datePickerController.setRangeLow("myElementID",$today);

datePickerController.setRangeHigh("myElementID",$old_dayes);

I want to set the dynamic date to ("myElementID","20081201"). Date Ranges: $todayand$old_days = 'dates older than $today'

+3
source share
3 answers

from document (note: this is exactly the link you sent!)

The choice of the limit date, i.e. setting date ranges

DatePicker , .

, "rangeHigh" / "rangeLow" YYYYMMDD String; , 13/03/1970 20/12/1999:

var opts = {                            
  formElements:{"inp1":"d-sl-m-sl-Y"},
  // Set a range low of 13/03/1970                
  rangeLow:"19700313",
  // Set a range high of 20/12/2009
  rangeHigh:"20091220"                
};      
datePickerController.createDatePicker(opts);

, ( )...

:

// Set the lower limit to be 01/12/2008
datePickerController.setRangeLow("myElementID","20081201");
// Set the upper limit to be 01/12/2009
datePickerController.setRangeHigh("myElementID","20091201");

HTML:

<input type="text" id="datepicker"/>

JavaScript:

var today = new Date();
var options = {
    formElements: {
        "datepicker": "d-sl-m-sl-Y"
    },
    rangeLow: today.getFullYear() + today.getMonth() + today.getDay(),
};
datePickerController.createDatePicker(options);
+3

. . :)

 $(function () {
       var date = new Date();
       var currentMonth = date.getMonth();
       var currentDate = date.getDate();
       var currentYear = date.getFullYear();

       $('#YourDatepicker').datepicker({
            maxDate: new Date(currentYear, currentMonth, currentDate)
       }); 
  });
+5

, upiic's:

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

NB. 0 .

+2

Source: https://habr.com/ru/post/1755270/


All Articles