Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there a way to localize input type="date" in HTML5

I know that at the time of this writing only Opera supports a browser UI for

<input type="date" name="mydate"> 

and maybe my attempts to localize this field have been met with frustration because niceties like localization have not yet been included in their implementation, but I don't even see mention of it in the HTML5 spec. Is there a way that localization should be specified? Should I do lang="fr" on a parent element?

Some notes on the implementation of the site in question:

  • Localization (language) is explicitly picked by the user because they are managing data in multiple languages and it is not reasonable to expect that the user's browser chrome is in the language being viewed or that the browser is providing desired language request headers.
  • I want to be sure that if the page is rendered in French that the date picker provided by browser chrome shows options that make sense for French language.
  • The plan is to fall back to jQueryUI for browsers that do not support type="date", I will use the detection mechanism provided in Dive into HTML 5
like image 328
lambacck Avatar asked Jun 03 '10 18:06

lambacck


People also ask

Is date a part of input type attribute in HTML5?

The input element with a type attribute whose value is " date " represents a control for setting the element's value to a string representing a date.

How do I change the input date format in HTML5?

To set and get the input type date in dd-mm-yyyy format we will use <input> type attribute. The <input> type attribute is used to define a date picker or control field. In this attribute, you can set the range from which day-month-year to which day-month-year date can be selected from.

Is input type date accessible?

Is there enough support for input type="date" to make it safe to use as part of an accessible website, or web based application? While some browsers have pretty good support for input type=”date”, including our accessibility requirements, our answer, sadly, has to be… “No”.

Are there any style options for the HTML5 date picker?

Currently, there is no cross browser, script-free way of styling a native date picker.


1 Answers

From what i know, the thinking behind what we do in Opera (full disclosure: I work for them) is that the date picker is almost an extension of the chrome, a browser-native control. As such, it will be localised according to the language of the browser, rather than the language of the page being viewed.

like image 129
Patrick H. Lauke Avatar answered Sep 17 '22 19:09

Patrick H. Lauke