Quantcast
Channel: ASPNETWebStack Issue Tracker Rss Feed
Viewing all articles
Browse latest Browse all 7215

Closed Issue: input type="date" not in correct format [457]

$
0
0
I just ran across this issue today in Chrome. If you create a page with the following

Model:

public class Model {
[DataType(DataType.Date)]
public DateTime LastModified { get; set; }
}

Page:

@Html.EditorFor(x => x.LastModified)

Generates This:

<input type="date" value="01/01/2001" />

However the specs require an RFC 3339 / ISO 8601 Date. The Chrome browser refuses to use the date in this format. Here is the line to the spec.

http://dev.w3.org/html5/markup/datatypes.html#form.data.date

In order to get this to work in MVC4 I have to use the following:

@Html.TextBox(
name: "LastModified"
value: Model.LastModified.ToString("yyyy-MM-dd"),
htmlAttributes: new { type="date" })



Viewing all articles
Browse latest Browse all 7215

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>