Forum Moderators: open

Message Too Old, No Replies

Putting an Image or Text in a Text Input Field with JavaScript

Google Custom Search can do it? How can I?

         

wfernley

1:38 pm on Mar 20, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Hey everyone,

I have a login form that has two input boxes - one for the username and for the password (complicated eh!).

I want to make the username feild say "Username" in text or an image and then when the user clicks the field to enter their info, it disappears. Is this possible with JavaScript? It would be similar to what Google does with their Custom Search text field.

Thanks in advance for your help!

Wes

BlobFisk

1:40 pm on Mar 20, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



onBlur and onFocus are what you want here. Fire a function onFocus to clear the text and if the input is empty onBlur then put the text back in.

HTH