SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Zealot
    Join Date
    Oct 2004
    Location
    uk
    Posts
    128
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    styling text value of textbox

    i have a few textboxes that are prepopulated using the text value to show 'First name' , 'Surname' etc and are removed on focus by the user.

    Can these be styled as currently they appear black but client wants them light grey, but i dont want the entered text to be affected just the initial displayed text.

    hows this done?

  2. #2
    SitePoint Member
    Join Date
    Jul 2011
    Location
    Ho Chi Minh city, Vietnam
    Posts
    12
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Please see following code, hope it will help you:

    Code:
    <html>
    <style>
    .init_text { color: lightgrey; }
    .init_text:focus { color: black; }
    </style>
    <body>
    <input class="init_text" type="text" value="Initial text" onchange="this.className = this.className.replace('init_text', 'entered_text');" />
    </body>
    </html>

  3. #3
    SitePoint Zealot
    Join Date
    Oct 2004
    Location
    uk
    Posts
    128
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    thanks

    for some reason im not seeing any effect on the initial text, its still black


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
  •