Search code examples
gwtuibinder

Watermark on Password text input using GWT


This has been addressed for C# in here by using jQuery or by changing dynamically the "input" type. The jQuery option is probably overkilling in GWT and the change of input type I think is not possible. What is the best way to do it using GWT?

is it really necessary to do two inputs (one for the watermark as TextInput and another one for the password as Password and switch between them?)


Solution

  • The easiest is to set the element's placeholder: passwd.getElement().setProperty("watermark"). Otherwise, use a label/span that you position on top of the input and show/hide as the field gets focused/blurred.