I want users to be able to change a Kendo UI Datepicker value only through its button and selecting the date from the pop-up. How can I prevent users from typing in the Date
On your input element add this attribute and value...
onkeydown="return false;"
This will disable typed input and still allow using the calendar control input.
Indeed, the widget does not restrict user while typing in the input. The reason for this behavior is explained here: Why widget does not restrict typing
Along with all other solutions shared in this thread, the one can create a custom Masked DatePicker, which will restrict the user to a specific date format. Check this how-to demo for more details:
Create Date Masking
**Note that this is not supported by Kendo UI as a built-in feature, hence you will need to use it on your own risk. The good news is that it works pretty good without known side effects.
.HtmlAttributes(new { onkeydown="return false" })
Justin's answer works, but it doesn't prevent a right mouse-click from pasting an incorrect value. You could use the oncontextmenu
to prevent a right mouse-click
oncontextmenu="return false;"
This would also prevent the number in the calendar from being copied though.