Katya S
Katya S

Reputation: 1353

KendoUI DateTimePicker (or similar) - make textbox un-editable but allow changing of date/time via provided buttons

I have a form which is using DateTimePicker on one of the inputs. I would like the user to be able to select the date/time by using the buttons which KendoUI attaches to the right of the input field, however I don't want the user to free-type into the text field (to save me having to verify formatting or rubbish input).

It is possible to add readonly attribute to the input, either in HTML or by calling .readonly() method on the DateTimePicker object. This makes the text field un-editable, however it also prevents the click events on the date/time selectors from firing.

So, how do I prevent the user from being able to edit the textbox field manually?

Thanks in advance.

Upvotes: 1

Views: 4246

Answers (1)

Atanas Korchev
Atanas Korchev

Reputation: 30671

Yes, you can set the readonly attribute only of the input from which the datepicker was created:

<input id="datepicker">
<script>
$("#datepicker").kendoDatePicker().attr("readonly", true);
</script>

Here is a live demo: http://jsbin.com/uwayit/1/edit

Upvotes: 3

Related Questions