Wrox Home  
Search P2P Archive for: Go

  Return to Index  

javascript thread: Default text in textbox


Message #1 by Imar Spaanjaars <Imar@S...> on Wed, 06 Sep 2000 09:20:29 +0200
Well, for those of you who got interested by the idea, I found the article 
after browsing through my history items for some time.

It's actually quite simple, all you have to do is define a textbox with an 
onFocus and onBlur event like this:

<INPUT TYPE="text" NAME="txtMailAddress" SIZE="50" VALUE="Enter Email" 
onFocus="if (this.value==this.defaultValue) this.value='';" onBlur="if 
(this.value=='') this.value=this.defaultValue;">


That's it.

Imar

At 09:20 AM 9/6/2000 +0200, you wrote:
>Hi there,
>
>I recently read an article (unfortunately I can't find it anymore) in 
>which they explained the following situation.
>
>- A textbox on a form has a (default) value, describing its purpose (for 
>example "Your first name here".)
>- When the textbox is clicked, the text disappears, so the user can type 
>his name
>- When the textbox loses focus, and the user didn't type any text, the 
>original value ("Your first name here") is restored.
>- When the user has typed in something, the value is not changed.
>
>Does anybody know how to accomplish this?? Is there something like an 
>field.OriginalValue property or something like that??
>
>I'd rather not store the original value in a variable, because I have 
>quite a lot of input fields.
>
>Imar
>
>
>



  Return to Index