Jump to content

form default text to re-appear after click out


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';">

 

 

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.