Hamza
Hamza

Reputation: 49

How can i make DatePickerFor a readonly?

i have the DatePickerFor and i want to make it readonly I want to force user to pick dates ,not being able to type them.

<td>@(Html.Kendo().DatePickerFor(model => model.DateRecherche).Max(DateTime.Today))</td>

Thanks.

Upvotes: 0

Views: 1863

Answers (2)

Hamza
Hamza

Reputation: 49

Adding the attribute readonly to an input tag will make it read only. You can do this with jQuery like this:

$(function () {
        $('.k-datepicker input').attr('readonly', 'true');
    });

Upvotes: 1

Andrei
Andrei

Reputation: 56688

Is it in their docs:

//DISABLE inputs
$("#datepicker").attr("readonly", true);
$("#monthpicker").attr("readonly", true);

So you will need a little bit of javascript along with your view code to implement this behavior

Upvotes: 1

Related Questions