5

I use input pattern html5 validation. My computer default language is Turkish, so I get the warning message in Turkish. Is there any way to change the warning message language from the codes so every visitor gets the message in language I select?

http://jsfiddle.net/xhqsB/104/

<form>
  <input type="text" pattern=".{5,10}">
      <input type="submit" value="Check"></input>
</form>

enter image description here

Ali Çarıkçıoğlu
  • 1,304
  • 1
  • 12
  • 21
  • Is appearing in Turkish because it is the language of your browser. Try changing the language of the browser and check if the message appears in English, for example. – PiLHA Aug 12 '13 at 12:10
  • 1
    Pilha, please read the question again. I don't want to change any setting. I want to change it from the codes, so every visitor sees the same message. – Ali Çarıkçıoğlu Aug 12 '13 at 12:11
  • In that case you can set `setCustomValidity` per javascript for the field fixed to the message you want and in whatever language you want. – Sven Bieder Aug 12 '13 at 12:12
  • Right, http://stackoverflow.com/questions/5478800/override-css-for-html5-form-validation-required-popup, http://stackoverflow.com/questions/5272433/html5-form-required-attribute-set-custom-validation-message – PiLHA Aug 12 '13 at 12:14
  • Pilha, they are not input type. I search an answer for input pattern. – Ali Çarıkçıoğlu Aug 12 '13 at 12:18
  • @AliCarikcioglu The way you want to have it is not existing. There is no input pattern to change the language of an input. The only way to force the standard behavior of using the system language is by overwriting it. – Sven Bieder Aug 12 '13 at 12:23

2 Answers2

4

The way you want to have it is not existing. There is no input pattern to change the language of an input. The only way to force a change of the standard behavior of using the system language is by overwriting it.

By following the links in the comments above, you will see an example how to overwrite it.

Sven Bieder
  • 5,515
  • 2
  • 21
  • 27
  • To be exact, the language of the `input` element can be set (using the `lang` attribute), but this has no effect on browsers’s error messages. The problem is that the the HTML5 features like `pattern` were not designed with localization in mind. Or, rather, they imply the idea that the interface is localized by the browser according to the *browser* locale, not the page locale. – Jukka K. Korpela Aug 12 '13 at 13:30
0

You have to overwrite the validation message as explained in this article: HTML5 form required attribute. Set custom validation message?

Community
  • 1
  • 1
n00b
  • 1,832
  • 14
  • 25