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

Show value on disabed date

2 Answers 24 Views
Date/Time Pickers
This is a migrated thread and some comments may be shown as answers.
Nguyen
Top achievements
Rank 1
Nguyen asked on 28 Apr 2020, 09:57 AM

i have datepicker with mindate: 04/25/2020. today is 04/28/2020 and i disabled dates  < today, so how can I display 04/25/2020 in datepicker

my code:

<p> $("#txtStartDate").kendoDatePicker({<br>   format: "MM/dd/yyyy",<br>   isReadOnly: true,<br>   disableDates: function (date) {<br>      return compareDates(date);<br>   }<br>});</p><p></p><p>function compareDates(date) {<br>        var date = date && date.setHours(0, 0, 0, 0);<br>        var systemDate = getSystemDate();<br>        return date <= systemDate;<br>    }<br><br>    function getSystemDate() {<br>        var systemDate = new Date();<br>        systemDate.setDate(systemDate.getDate() - 1);<br>        return systemDate.setHours(0, 0, 0, 0);<br>    }</p>

2 Answers, 1 is accepted

Sort by
0
Nguyen
Top achievements
Rank 1
answered on 28 Apr 2020, 09:59 AM

$("#txtStartDate").kendoDatePicker({

    format: "MM/dd/yyyy",

    isReadOnly: true,

    disableDates: function (date) {

         return compareDates(date);

    }

});

function compareDates(date) {

    var date = date && date.setHours(0, 0, 0, 0);

    var systemDate = getSystemDate();

    return date <= systemDate;

}

 

function getSystemDate() {

    var systemDate = new Date();

    systemDate.setDate(systemDate.getDate() - 1);

    return systemDate.setHours(0, 0, 0, 0);

}

0
Nikolay
Telerik team
answered on 30 Apr 2020, 09:44 AM

Hi Nguyen,

The value for the DatePicker input can be set directly in the input used for the widget initialization:

 <input id="datepicker" value="4/25/2020" title="datepicker" style="width: 20%" />

Here I have prepared a small Dojo using the provided code. Can you please elaborate on giving more information about the use-case? Does the initial value need to be one that is in the disabled scope?

Also, below I am posting the DatePicker API. All the available configuration settings, methods, and events for the Kendo DatPicker can be found there with more details and examples.

Let me know if you have any questions

Regards,
Nikolay
Progress Telerik

Progress is here for your business, like always. Read more about the measures we are taking to ensure business continuity and help fight the COVID-19 pandemic.
Our thoughts here at Progress are with those affected by the outbreak.
Tags
Date/Time Pickers
Asked by
Nguyen
Top achievements
Rank 1
Answers by
Nguyen
Top achievements
Rank 1
Nikolay
Telerik team
Share this question
or