tags:

views:

56

answers:

1

Im using DatePicker plugin for a project. But I want to Disable dates older than today .(User couldnt select the old dates) My js is:

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

In manual :Both methods accept an Object that represents the dates or date ranges to disable. I couldnt disable the old days yet with many trial and error. Can you please show me any way to do this? Thanks in advance

Edit:

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

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

I want to set dynamic date in ("myElementID","20081201") . Date ranges : $today and $old_days = 'dates older than $today'

+2  A: 

from the docu (note: this is exactly the link you've posted!)

Limiting date selection i.e. setting date ranges

The datePicker enables you to define both a lower and upper limit for date selection.

To add a lower or upper limit, just add the parameters “rangeHigh” and/or “rangeLow” to the initialisation object and set their values to be a YYYYMMDD date format String; for example, the following code will limit date selection outside of the range 13/03/1970 to 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);

for those, who are not willing to scroll (just one line down in the docu)...

Setting the date range dynamically

The upper and lower date ranges can also be set programmatically by calling the following two methods:

// 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");

edit:

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);
Andreas Niedermair
I doesnt disable dates dynamically.
phpExe
see my edit!...
Andreas Niedermair
@Andreas; I know issues in manual. Above dates may be dynamic. $today and $datesolderthantoday that set dynamic. But Im not very familliar with js. My question is that how can set this date dynamically.
phpExe
you may elaborate! what is `$tody` and `$datesolderthantody`? please support some code of what you've tried!
Andreas Niedermair
I have edited my question.
phpExe
see my edit!...
Andreas Niedermair
btw: provide more code next time!
Andreas Niedermair