Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6796975
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T18:33:08+00:00 2026-05-26T18:33:08+00:00

How do I separately style the text inside the search field (on the right)?

  • 0
  1. How do I separately style the text inside the search field (on the right)?
    I want to have light grey color when there’s a default text (SEARCH) and I want a black color when a person inputs a word.

    • I tried wrapping the function inside the new div tag but no use, it gives me a PHP error.

    • I used FireBug to track the problem but couldn’t figure it out on my own.

  2. When you write something in the search (don’t press Enter) and then click away, the text you wrote stays inside a search field. What can I do to get the effect so that whenever you click away from the search field, it resets to a default word (SEARCH in this case)?

    • I tried playing with onblur and onfocus but I don’t know what to change to get a desired behavior.

    • I also used a code for form reset but that just gives me the button that you have to click to reset to default text.

  3. If the answer to the second question is too complex, I’d like to get the following instead:

    • When the site loads – search field says SEARCH.

    • When you input something (don’t press Enter) and click away, the text that you input stays BUT…

    • … When you click that search field again, the previously input text is completely selected so that if you start writing something new, the search field shows only the new text. (At the moment, if you click the filed after clicking away, your new text is just added to the text you input before it).

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T18:33:09+00:00Added an answer on May 26, 2026 at 6:33 pm

    This works for both #1 and #2 for me (tested in FF, not sure about IE).

    The onclick checks if the default value is still in the search field, if it is, it gets cleared out and the user can type something in black text.

    When they click away, the onblur event fires and checks if the default value is present. If it isn’t, the value gets reset and changed to a light gray.

    <input type="text" name="search" value="SEARCH" style="color: #DDDDDD;"
        onclick="javascript: if( this.value == 'SEARCH') { this.value = ''; this.style.color = '#000000'; } "
        onblur="javascript: if( this.value != 'SEARCH') { this.value = 'SEARCH'; this.style.color = '#DDDDDD'; }" />
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have the following in my index.xhtml style type=text/css media=screen and (min-width: 500px) @import
I have this fiddle where there is a rollover style applied to a paragraph
I have tried EVERYTHING to be able to style JUST text inputs with internet
I´m trying to separate a gridViewColumn into two rows. Im using default style for
I have two DLLs compiled separately, one is compiled from Visual Studio 2008 and
i have a problem..my tabs name show too big i want it shows as
<div style=position: absolute; top: 0px; left: 0px; right: 0px; bottom: 0px;> <div style= border:
I have some dynamic text contained in a div that is set to whatever
I have a div that has it's opacity set to 60. Inside the div,
I have the following file file: <html> <head> <title></title> <script type=text/javascript src=/Prototype.js></script> <script type=text/javascript>

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.