开发者

Google Chrome input type="date"

I have almost no knowledge of web programming, but I have been tasked to solve something on my company's website. Apparently, I have an issue with browsers using HTML5 on a legacy site using type="date" and I need to find a way around it.

My site has a lot of date fields that the user must input like such:

 <input type="date" name="DateStart" size="15" value="8/30/2011">

In every browser we c开发者_运维百科urrently use except Chrome, this works just fine. Chrome is the only browser that supplies rolling buttons to scroll through the date. What I see on the back end of this is an attempt to do this:

FormatDateTime(DateStart, 2)

I get an invalid date error which means that we cannot use Chrome to fill out this form. Is there a way around this problem?


Actually chrome's support for 'date' is broken. (See here). At least for the moment.

The use of 'date' in the HTML is absolutely fine - browser's which do not know of or support an input type are supposed to fallback to type='text'.

Currently chrome partially supports date, in a way that is essentially broken (it adds a couple of up-down buttons, but no datepicker.)

Of course you do need to bear in mind that if you are using type='date', and if the browser supports it, then you'll want to disable whatever datepicker support you'd otherwise be using.

UPDATE (6 Feb 2012):

It looks to me like this is now fixed. Chrome no longer claims to support input type='date', and does not provide the partially complete implementation.

UPDATE (17 Aug 2012):

Chrome does now have input type="date" support, and it's more functional this time.


Chrome does not have issues with date-inputs, you are using the wrong date-format, sir. Chrome isn't the only browser until today which has support for the new HTML5 inputs. Opera for example displays a dropdown with a calendar on inputs with type="date".

Also the size-attribute does not exist on HTML5-date-inputs.


The value field for the input type = input needs to be in the format yyyy-MM-dd. Check the W3 standards on this.

This means you must do something like DateTime.Now.ToString("yyyy-MM-dd"). in your code, I would suggest a custom HtmlHelper.

The format of the date in the browser is completely dependent on your system settings.


Use this date format : date("Y-m-d");

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜