Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

set the max date on kendo date picker from client side

I have this:

var today = new Date();

Updating the kendo datepicker:

$('#datepicker').kendoDatePicker({
    max: today.setDate(today.getDate()+30);
});

In the debugger the max value is 1404408808080 but in today variable the date is right one 2014-07-03T17:3. Want to set the max date for kendodatepicker 30 days from the current date.

like image 403
GANI Avatar asked Jun 03 '14 17:06

GANI


People also ask

How to set max Date in kendo DatePicker?

kendoDatePicker({ max: today. setDate(today. getDate()+30); });

How do I set a DatePicker range?

Steps to add Datepicker – $(document). ready(function(){ $("#setMin,#setMax"). datepicker({ dateFormat: "yy-mm-dd" }); $('#datepicker'). datepicker({ dateFormat: "yy-mm-dd", maxDate:'+1m +10d', minDate: -10 }); });

How do I disable kendo DatePicker?

By default, the DatePicker is enabled. To disable the component, set its disabled property to true .


1 Answers

You have to use the setOptions() method to change that:

var datepicker = $("#datepicker").data("kendoDatePicker");

datepicker.setOptions({
    max: new Date(today.setDate(today.getDate()+30))
});

Or if you want just do this in the initialization:

$("#datepicker").kendoDatePicker({
    max: new Date(today.setDate(today.getDate()+30))
});
like image 86
DontVoteMeDown Avatar answered Oct 21 '22 03:10

DontVoteMeDown