I am using Telerik's timepicker in an MVC razor view.
@(Html.Kendo().TimePicker()
.Name("StartTime")
.HtmlAttributes(new { title = "Start Time" })
.DateInput()
.Interval(15)
)
By default, it renders like this
In the viewmodel class, I have defined StartTime as nullable type (public DateTime? StartTime { get; set; }). Users may choose not to fill the timepicker.
In the controller, when I am checking if ModelState is valid, if the user doesnt fill the timepicker, the ModelState is invalid and the ModelState error is
The value 'hours:minutes AM/PM' is not valid for Start Time
Try to remove the .DateInput()
to be like:
@(Html.Kendo().TimePicker()
.Name("StartTime")
.HtmlAttributes(new { title = "Start Time" })
.Interval(15)
)
and check if the problem is solved.