Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

HTML

How to set up the language of a form (HTML5)

Hello guys, I know that there is a way to set up this the way I like, once you put the required attribute, you know that if the input ins't filled out, then a message will come up, whether the Browser is in spanish, the html5 error message will be in spanish, or if the Browser is in english, then the error will be in english.

My question: how can I do to set up the language of those messages in spanish by default?

now my simple form:

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

1 Answer

Hey Marcelo,

For the form only, and not the entire document, I think this might be what you're looking for. There's more information at Declaring Languages in HTML 5.

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

Unfortunately i think most browsers will still default to using the OS's language for these type of validation messages. Trying this locally in Chrome on OS X with English set as the default language the page is detected as being in Spanish but all validation messages are still in English.

That makes sense, and I think I can vouch for that actually. Thanks for clearing that up.