0

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

enter image description here

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
blue piranha
  • 3,706
  • 13
  • 57
  • 98
  • Well, the solution would be to achieve an empty value for `start time` input if user doesn't specify time. But I don't know how to do it with **Telerik** – Alexander Sep 17 '19 at 19:35

1 Answers1

0

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.

Hosam.Yousof
  • 107
  • 9