+ Reply to Thread
Results 1 to 3 of 3
  1. #1
    Join Date
    Dec 1969
    Posts
    604

    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
    95,774

    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
    604

    Default Thanks Bill

    Excellent - thanks Bill!

Bookmarks

Posting Permissions

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


More ASP Resources

Resources:
-- ASP Articles
-- ASP.NET Information
-- 4Guys ASP F.A.Q.
-- ASPFAQs.com
-- ASP Coding Tips
-- Related Web Technologies
-- User Tips!!
-- ASP-related ListServs
-- HTML5 Development Center
-- JavaScripts


Smart Sites
-- Mobile Development Center
-- MSDN SpotLight
-- Web Dev Resource Center
-- Cloud Showcase for Developers


Windows Technology
Check out these Web sites for articles, tutorials, FAQs, discussions, and code on ASP and related technologies!
-- CodeGuru.com
-- VBForums.com
-- ASPFAQs.com
-- ASPMessageboard.com
-- DevX.com
-- Developer.com
-- FreeVBCode