Search code examples
javascriptjquerykendo-uikendo-datepicker

Set Today date to kendo datepicker


I want to set today date to Kendo DatePicker on clear button click. I tried following but it is not working.

$('#btnClear').click(function () {
  $("#StartDate").data("kendoDatePicker").value(new Date());
});

Above code don't give any error and don't set today date. It clears kendo DatePicker's textbox value. Note: Kendo DatePicker format is MM/dd/yyyy.


Solution

  • I tried following and works perfectly for me.

    $('#btnClear').click(function () {
      var todayDate = kendo.toString(kendo.parseDate(new Date()), 'MM/dd/yyyy');
      $("#StartDate").data("kendoDatePicker").value(todayDate);
    });