Jump to content

form default text to re-appear after click out


87dave87

Recommended Posts

Hi,

 

I have a text box which contains a default value which disappears when a user clicks into it to type something: -

 

<form method="post" action="/search.php" onsubmit="return dis(this)">
          <a href="/"><strong>Home</strong></a><strong> | <a href="/about.php#bookmark">Bookmark 
          Us</a> | Find Emulator:</strong> 
          <input name="emusearch" type="text" value="e.g. Stella or Atari 2600" onfocus="if(this.value==this.defaultValue) this.value='';">
          <input type="submit" value="Go">
    </form>

 

What code do I need to use to make it so that if the user clicks out of the box it displays the 'e.g. Stella' again?

 

I know its something to do with default value... but can'tfind the code to use.

 

Thanks.  :)

<form method="post" action="/search.php" onsubmit="return dis(this)">
          <a href="/"><strong>Home</strong></a><strong> | <a href="/about.php#bookmark">Bookmark 
          Us</a> | Find Emulator:</strong> 
          <input name="emusearch" type="text" value="e.g. Stella or Atari 2600" onfocus="if(this.value==this.defaultValue) this.value='';" onblur="this.value='e.g. Stella or Atari 2600';">
          <input type="submit" value="Go">
    </form>

<input name="emusearch" type="text" value="e.g. Stella or Atari 2600" onblur="if(this.value=='') this.value='e.g. Stella or Atari 2600';">

 

I search 'stella' and it returned a result the result of your search will be an issue with the search script - this js for controlling the default value won't affetc it...

<input name="emusearch" type="text" value="e.g. Stella or Atari 2600" onblur="if(this.value=='') this.value='e.g. Stella or Atari 2600';">

 

I search 'stella' and it returned a result the result of your search will be an issue with the search script - this js for controlling the default value won't affetc it...

 

How do i make it so that when I click into the box all the default text disappears? at the moment you have to delete it yourself.

Yeah its in the firts reply - I simply made an adjustment to the onblur but deleted the other - sorry

 

Here it is in all its glory

 

<input name="emusearch" type="text" value="e.g. Stella or Atari 2600" onfocus="if(this.value==this.defaultValue) this.value='' onblur="if(this.value=='') this.value='e.g. Stella or Atari 2600';">

 

 

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.