This is a migrated thread and some comments may be shown as answers.

Clearing a date picker

1 Answer 1243 Views
Date/Time Pickers
This is a migrated thread and some comments may be shown as answers.
todd
Top achievements
Rank 1
todd asked on 12 Aug 2020, 12:42 PM

I have seen multiple articles about clearing a date picker but they don't work.  Multiple posts say this should do it:

jQuery("#datepicker").data("kendoDatePicker").value(null);

This clears the display, but it does not show the placeholder text that's there before a value is selected.  I would expect that to happen automatically when the value is set to null, but since it doesn't, how do I make that happen?

 

 

 

1 Answer, 1 is accepted

Sort by
0
Silviya Stoyanova
Telerik team
answered on 14 Aug 2020, 11:17 AM

Hello Todd,

The Kendo UI DatePicker with a dateInput is designed this way so when the user presses backspace the section is deleted and the placeholder shows.  However, if you manually remove the value the input mask is lost. To keep the input mask I would suggest using the setOptions() method  and reset the format option as follows:

$("#btn").click(function(){
    var datepicker = $("#datepicker").data("kendoDatePicker")
    datepicker.value(null);
    datepicker.setOptions({ format: "MM/dd/yyyy" });
  });
Here is a dojo example: https://dojo.telerik.com/@Silvia/AhOQOKUZ

I hope that helps.

Kind Regards,
Silviya Stoyanova
Progress Telerik

Tags
Date/Time Pickers
Asked by
todd
Top achievements
Rank 1
Answers by
Silviya Stoyanova
Telerik team
Share this question
or