- From: Ben Darlow <ben@kapowaz.net>
- Date: Tue, 17 Jan 2012 11:49:22 +0000
I've recently been implementing date controls for a web application to be primarily used on mobile browsers, and discovered that the placeholder attribute is considered forbidden for use on input[type=date] elements. I would like to propose that this be changed. Since the spec does not (and should not) mandate the specific implementation of the interface to a date element, not permitting a placeholder means that where a browser chooses to implement the control in a similar vein to an ordinary text input (i.e. with free text entry), this control can't follow the same pattern of label + example via placeholder. I've mocked this up with a use case which I foresee as being relatively common where the browser implements the control like this: https://img.skitch.com/20120117-tmh1bu3wxcarxr94kyk147h3k2.png Another issue with input[type=date] elements relates to how the *value* of the date and how it is *displayed* may want to be different. In iOS 5.0, Mobile Safari implements the input[type=date] control with a native spin control, but as this is independent of how the control is displayed within the webpage itself (unlike the more text input-like approach), it also formats the date in a different format to the ISO format that input[type=date] mandates (example: https://img.skitch.com/20120117-grwdr7ebd56iww617ypatqqa88.png). The ISO date format has the advantage over different local date formats in that it is unambiguous, but it isn't necessarily the most user friendly. I would like therefore to propose that an optional dateformat attribute be added to the input element, to permit different formats to be used to * display* a selected date. My initial feeling is that some flavour of the strftime syntax implemented by several languages (e.g. http://ruby-doc.org/core-1.9.3/Time.html#method-i-strftime) is probably the best way of specifying the format within this attribute. An example usage of this might thus be: <input type="date" name="dateofbirth" dateformat="%-d %b, %Y"> This would then create a date input whose selected date would be formatted as per the screenshot above. Comments or observations of important points I've missed welcomed! ~B
Received on Tuesday, 17 January 2012 03:49:22 UTC