KnowledgeHub
Questions
Tags
Users
Search
Alex Rivera
|
Logout
Edit Question
Title
Body
I have a DateTime property in my model, but I'm only interested in the time part: public class MyModel { [Required, DataType.Time] public DateTime Time } In my view, I output it like so: @Html.EditorFor(model => model.Time) This used to generate the following html in MVC 3: <input class="text-box single-line" data-val="true" data-val-required="The Time field is required." id="Time" name="Time" type="time" value="" /> Now I'm trying this with MVC 4, and this is the html generated: <input class="text-box single-line" data-val="true" data-val-date="The field Time must be a date." data-val-required="The Time field is required." id="Time" name="Time" type="time" value="" /> There is an extra attribute data-val-date added, which results in a client side validation error, because a time (e.g. "10:30") isn't formated as a date. I suppose this is a bug in MVC 4 ( I reported it )? But until it's resolved, is there any way to prevent this attribute from being generated? Or even better, is there a way to let it be generated as a data-val-time in stead, so I can provide my own client side validation method for time fields?
Tags (comma-separated)
Save Edits
Cancel