This is a migrated thread and some comments may be shown as answers.

[Solved] The field <variable> must be a valid date

3 Answers 137 Views
Date/Time Pickers
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Deepak
Top achievements
Rank 1
Deepak asked on 09 Mar 2012, 12:29 AM

Hi there,

I'm trying to use the TimePicker with ASP.NET MVC 4.0 but keep seeing the validation message "The field StartTime must be a valid date" as soon as I select a time no matter what time I select.  The TimePicker is bound to a DateTime property in a model object as follows. 

@Html.Telerik().TimePickerFor(m => m.StartTime).Interval(60)
@Html.ValidationMessageFor(m => m.StartTime)

Here's the generated HTML:

<div class="t-widget t-timepicker"><div class="t-picker-wrap"><input class="t-input" data-val="true" data-val-date="The field StartTime must be a date." data-val-required="The StartTime field is required." id="StartTime" name="StartTime" type="text" value="6:24 PM" /><span class="t-select"><span class="t-icon t-icon-clock" title="Open the time view">Open the time view</span></span></div></div>

I also have the following below:

jQuery(

 

 

 

'#StartTime').tTimePicker({format:'h:mm tt', minValue:new Date(2012,2,8,0,0,0,0), maxValue:new Date(2012,2,8,0,0,0,0), interval:60, selectedValue:new Date(2012,2,8,18,24,6,627)});

 

Any thoughts why I keep seeing the validation message even though I'm selecting a valid time?

Thanks much.

Deepak.

3 Answers, 1 is accepted

Sort by
0
Trevor
Top achievements
Rank 1
answered on 17 Oct 2012, 07:24 PM
Deepak,

I'm experiencing the same issue with the date picker.

Were you able to find a resolution?

Greg
0
Deepak
Top achievements
Rank 1
answered on 17 Oct 2012, 07:31 PM
Try binding to a TimeSpan data type.  I believe that solved the issue for me.  (It's been a while since I have seen it).
0
Trevor
Top achievements
Rank 1
answered on 17 Oct 2012, 07:33 PM
Thanks Deepak, I'll give that a shot.

Greg
Tags
Date/Time Pickers
Asked by
Deepak
Top achievements
Rank 1
Answers by
Trevor
Top achievements
Rank 1
Deepak
Top achievements
Rank 1
Share this question
or