Actually I'd recommend not puting the placeholder in the input itself,
assuming you don't have to support old browsers that most other now have
stopped supporting a few years back. Depending on the browser of your
users, you can:
- use the html5 placeholder attribute (best way to do that, but you
won't support ie < 10)
- have the placeholder appear in the input while it's not; one nice
technique is to use a label/span that you will move above the input with
css (using position attribute and z-index); then you have a little
javascript that will simply change the opacity of that placeholder
depending on conditions: with an initial opacity of 1, you can put it at
0.5 when the user focus the field, and at 0 once he entered anything.
Advantages of that compared to putting the placeholder in the input is
you don't have to worry about the placeholder value being actually
submitted by the client, and that you won't have any bloat to have the
placeholder back if the user empty the field.
Note that for the second option, you need opacity, and thus either IE8+
or have the proprietary ms syntax for that (IE5-7 using filter:
alpha(opacity=50);, IE8 using
-ms-filter:"progid:DXImageTransform.Microsoft.Alpha(Opacity=50)";)
Sven Meier wrote:
"oncklick"
... or "onclick" ?
I'd recommend a javascript only solution without round-trip to the
server.
http://stackoverflow.com/questions/2851794/clear-text-onclick-textfield
Sven
On 11/27/2012 05:09 PM, Dmitriy Neretin wrote:
Hi wicket-users,
I have a question about a combination of the TextField and
AjaxFormComponentUpdatingBehavior.
I have a text field with content. Just to indicate what user should
enter.
For example a day text filed, which already contains following "DD".
I do it by following:
dayField.setModel(Model.of("DD"));
My idea now is to delete this text automatically. For example with
"oncklick" event. What I did is:
dayField.add(new AjaxFormComponentUpdatingBehavior("oncklick"){
onUpdate(){
doSomeStuff
}
});
So, the problem now is it doesn't work at first time! For example I
click
in the field, delete the text, insert another text, leave the field.
Click
in the filed again and only then onUpdate method performs. But it
doesn't
perform at first time and I don't understand why...
Can somebody help me?
Regards,
Dmitriy
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
For additional commands, e-mail: users-h...@wicket.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
For additional commands, e-mail: users-h...@wicket.apache.org