supercobra supercobra - 1 year ago 455
HTML Question

How to add a placeholder to a GWT text input field

Does any know of a Google Web Toolkit text input widget that would display a message inside the field when it is empty?

E.g. a first name field that would say: 'enter your first name' and when the user starts typing the label is removed to show the typed text.

How would you go about this?


Answer Source

This does the work for me in a textarea:

yourInputField.getElement().setPropertyString("placeholder", "enter your first name");

I think it is a HTML5 feature.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download