2

Hello I was playing around with HTML5 datePicker and I was wondering how I could change the default language of the widget. How to change the lang from english to german? Any idea?

<form action="/action_page.php">
  Birthday:
  <input type="date" name="bday">
  <input type="submit">
</form>

Thanks

Liam
  • 27,717
  • 28
  • 128
  • 190
Micheal Muller
  • 47
  • 1
  • 2
  • 7
  • 2
    AFAIK you can't. This is controlled by the browser's locale, which can only be set by the user. I,e, users whose Chrome (or iOS or whatever), is set to German will have a German datepicker. – Amadan Nov 12 '18 at 13:05
  • Possible duplicate of [Is there any way to change input type="date" format?](https://stackoverflow.com/questions/7372038/is-there-any-way-to-change-input-type-date-format) – Liam Nov 12 '18 at 13:12

3 Answers3

1

the most common way to force to change the language is the next :

<form lang="es">
        <input type="text" pattern="\d{1,15}" required />
        <input type="submit" />
    </form>

if you want more information about declare language, can you learn more in the next links :

http://nimbupani.com/declaring-languages-in-html-5.html

I hope my answer is helpful.

Liam
  • 27,717
  • 28
  • 128
  • 190
  • Neither this nor the meta tag worked for me (on Chrome). The datepicker remained localized in the same language used by the browser. – nonzaprej Oct 19 '20 at 12:53
0

This works on safari but not in Chrome or Firefox:

<form action="/action_page.php">
  Geburtstag:
  <input type="date" name="bday" placeholder="tt/mm/jj">
  <input type="submit" value="einreichen">
</form>

However you can use polyfills to make it work on all browsers. Look at this example of a module to understand it better.

Wimanicesir
  • 4,606
  • 2
  • 11
  • 30
0

type date for html is browser native control, at least for chrome this stands true. So it will be localised according to the language of the browser. However frameworks like bootstrap has better locale support or even you can set locale settings in jquery manually with some scripting at server side.

Robus
  • 465
  • 6
  • 19