2

We're working on a .NET MVC mobile site. I understand that on the iPhone, mobile safari will display a datepicker for the following input field:

<input type="date"/>

We have a standard date picker helper which spits out date picker options for various platforms. In this case we detect mobile safari and then write out an input field that is bound to our model:

<input name="StartDate" value="2008/12/21" type="date"/>

The problem is that the value portion is not shown on load. We can enter in new values, and save them back to our database. But then when we reload the page those values don't show up in the fields. If we save again, our values are all set back to null in the db.

I noticed that when you select a date with the wheels on the iPhone, the value of the text field ends up in the format similar to "Apr 6, 2012" where as I'd expect it to show 2012/04/06 or 04/06/2012.

My guess is that the mobile safari displays a different attribute of the field, and then sets the value attribute appropriately behind the scenes.

Does anyone know what's going on with this? Thanks!

4

1 回答 1

5

AFAIK the date must be RFC3339 compliant. Have you tried 2008-12-21 (dashed instead of slashes)?

<input type="date" value"yyyy-MM-dd" />
于 2012-04-06T23:44:42.943 回答