Text box onfocus

Results 1 to 3 of 3

Thread: Text box onfocus

  1. #1
    Join Date
    Dec 1969
    Posts
    659

    Default Text box onfocus

    Hi guys

    I'm currently using the following code in my text boxes so that if a user clicks on the box the value dissappears:

    <input type="text" name="address1" size="44" value="Full name" onFocus="this.value=''">

    This works great but is there a way that if the user then clicks on something else (eg a different text box) the original value reappears in the box?

    Any help would be fully appreciated

    Best regards

    Rod from the UK

  2. #2
    Join Date
    Dec 1969
    Posts
    96,017

    Default

    Code:
    <input type="text" name="address1" size="44" value="Full name" 
           onfocus = "this.value='';"
           onblur = "if ( this.value == '' ) this.value=this.defaultValue;" />
    If for some reason that doesn't work, you could instead do
    Code:
    <input type="text" name="address1" size="44" value="Full name" 
           onfocus = "this.value='';"
           onblur = "if ( this.value == '' ) this.value='Full name';" />

  3. #3
    Join Date
    Dec 1969
    Posts
    659

    Default Thanks Bill

    Excellent - thanks Bill!

Posting Permissions

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