Results 1 to 4 of 4
  1. #1
    Join Date
    Sep 2003
    Location
    Montreal, Canada
    Posts
    373

    [HTML] onfocus and offfocus?

    I have this line in my html:

    PHP Code:
    <input name="search" value="Type your question here" onfocus="this.value=''" class="input" type="text"
    When I click in the box, it becomes empty,
    However I'd like it to revert to the original text once it loses focus and I can't make it happen.

    I've tried offfocus, outfocus, nofocus and none of those seems to work. And google is of no help.

    So my question would be, what is the reverse code for onfocus?

    Thank You

  2. #2
    Join Date
    Feb 2005
    Location
    Australia
    Posts
    5,842
    onblur ...
    Chris

    "Some problems are so complex that you have to be highly intelligent and well informed just to be undecided about them." - Laurence J. Peter

  3. #3
    Join Date
    Sep 2003
    Location
    Montreal, Canada
    Posts
    373
    Thank You
    I would of never guessed this heh

  4. #4
    Join Date
    Sep 2000
    Location
    Alberta, Canada
    Posts
    3,109
    To give an example.

    <label for="text-realname">Name:&nbsp;</label>
    <input id="text-realname" type="text" name="realname" value="Enter Name" maxlength="30" onfocus="if(this.value=='Enter Name')this.value='';" onblur="if(this.value=='')this.value='Enter Name';" />


    The 'label' code is for accessability friendly, which is always a good idea to code for.
    PotentProducts.com - for all your Hosting needs
    Helping people Host, Create and Maintain their Web Site
    ServerAdmin Services also available

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •