且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

使用GWT在密码文本输入上加水印

更新时间:2023-11-14 15:32:34

最简单的是设置元素的占位符: passwd.getElement()。setProperty(watermark)。否则,请使用位于输入顶部的标签/跨度,并在字段变得焦点/模糊时显示/隐藏。


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?)

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.