Forum Moderators: open

Message Too Old, No Replies

text box with a default line of text

text box with a default line of text

         

anubis

10:22 am on Sep 24, 2002 (gmt 0)

10+ Year Member



Hi

I have a form text box with a default line of text in it. Does any one know of a way where when the user clicks on the text box the default text disappears and they can just type their query.

cheers

Anubis

knighty

10:39 am on Sep 24, 2002 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



<input type=text name="words" value="Text goes here" size="10" onfocus="this.value=''">

NameNick

11:14 am on Sep 24, 2002 (gmt 0)

10+ Year Member



As expansion to knighty's example the following code will put the default text line back into the text field, if the user types nothing and clicks outside the text field.

<input type="text" name="email" value="your@email.com" onFocus="if (value == 'your@email.com') {value=''}" onBlur="if (value== '') {value='your@email.com'}" size="15">

NN

tedster

2:26 pm on Sep 24, 2002 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



That's a nice enhancement, NameNick. It goes into my snippets box. The thought would never have crossed my mind.

anubis

3:03 pm on Sep 24, 2002 (gmt 0)

10+ Year Member



thanks guys

anubis