Sandro Adamia
Sandro Adamia

Reputation: 463

kendo ui datepicker required field

Hi how to make Kendo UI DatePicker as a required field ? I added required attribute to an input element

@Html.TextBoxFor(model => model.POAStartDate, new { id="POAStartDate", Name="POAStartDate",data_id="POAStartDateCreate",required="true", data_class="poaDatePicker", @class="field-date", @readonly="readonly"})

Upvotes: 1

Views: 8153

Answers (3)

Sandro Adamia
Sandro Adamia

Reputation: 463

Solved, the problem was with readonly attribute, when u put readonly with required together on kendo ui datepicker, kendo ui validator doesn't validate it on reqiured rule, if u still want prevent user from entering wrong data in datepicker u should use custom validation rule here is an example http://jsbin.com/eleyeh/4/edit

Upvotes: 3

Petur Subev
Petur Subev

Reputation: 20223

I see that you have added the required attribute manually, all you need to do now is to initialize the Kendo validator over your form which contains the datepicker. Check here.

Upvotes: 0

Kirill Bestemyanov
Kirill Bestemyanov

Reputation: 11964

You should add [Required] to POAStartDate property of your model.

Upvotes: 0

Related Questions