This is a migrated thread and some comments may be shown as answers.
DatePicker does not honour the readonly attribute
2 Answers 154 Views
This is a migrated thread and some comments may be shown as answers.
Rik
Top achievements
Rank 1
Rik asked on 04 May 2012, 12:43 PM
If I create a read only input field that uses a KendoUI date picker element, It still appears to be possible to change the date...

for example
<input id="startDate" type="date" name="startDate" value="1 Sep 2011" readonly="readonly" data-role="datepicker" data-format="d MMM yyyy"  />

In Chrone, the field appears to be read only, and you can't click in the field and manually edit it with the keyboard.
However, you can click on the Kendo UI Calendar icon, which pops up a calendar. Using the calendar, you can choose a new date like normal, which updates the text in the field.

Is there something I should be doing to prevent this? Is it a bug?

2 Answers, 1 is accepted

Sort by
0
Brady
Top achievements
Rank 1
answered on 07 May 2012, 04:33 PM
I figure DatePicker doesn't feature a read only capability because if the date is read only, you don't need a picker. Except for uniform styling, something that all widget libraries universally ignore.

I use this workaround, and it works fine except for a very slight flicker when you click the calendar icon:

$(".datepicker-readonly").kendoDatePicker({
    format: "yyyy/MM/dd",
    open: function (e) {
        e.preventDefault();
    }
});
$(".datepicker-readonly").attr("readonly", "readonly");
0
Jan Houwen
Top achievements
Rank 1
answered on 17 Jun 2013, 11:55 AM
Is it possible to do this dynamically, e.g. when switching from a form in view-mode to a form in edit-mode? Just changing the .open property of a control (after instantiation) is not effective.
Asked by
Rik
Top achievements
Rank 1
Answers by
Brady
Top achievements
Rank 1
Jan Houwen
Top achievements
Rank 1
Share this question
or