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

  • SEARCH
  • Home
  • 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 7865999
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T00:15:23+00:00 2026-06-03T00:15:23+00:00

I have a input box which looks like below, <input id=basic-search type=text value=Enter keyword

  • 0

I have a input box which looks like below,

<input id="basic-search" type="text" value="Enter keyword or phrase" title="basic-search" class="form-text" size="38" onclick = "this.className = 'focused'; javascript:Reset();" onblur = "javascript:Reset();" />

and css for .focused and form-text is,

.focused {
color:black;
}

.form-text
{
    background-color: #FFF;
    color: #CCC;
}

The input box on load has the content ‘Enter keyword or phrase’ which is grey initially. Onclick on this box and on typo the font color changes to black(works good). When the delete the contents, tab to next field or on mouse press the content ‘Enter keyword or phrase’ changes to black. It should still be grey. What change should i make in the css? any inputs would help. Thanks.

Note: I noticed the ‘title’ field in stackoverflow works as I would want. I want my boc to work the same way.

  • 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-06-03T00:15:25+00:00Added an answer on June 3, 2026 at 12:15 am

    Use onfocus instead of onclick. Also, for your onblur, append the css class:

    jsFiddle: http://jsfiddle.net/QybRX/14/

    <input id="basic-search" type="text" value="Enter keyword or phrase" title="basic-search" class="form-text" size="38" onfocus="this.value=''; this.className = 'focused'; javascript:Reset();" onblur = "basicSearch()" />
    <input type="text"/>
    
    <script>    
        function basicSearch()
        {
            var element = document.getElementById("basic-search");
    
            if ( element.value.length == 0 )
            {
                element.value = 'Enter keyword or phrase';
                element.className = 'form-text';
            }
            else
            {
                element.className = 'focused';
            }
    
            javascript:Reset();
        }
    </script>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an input box <input type=text name=search id=search /> <img src=icon.png alt= id=doSearch
I have an text input box which needs to be used as a search.
I have a input text box in html for user to type in quantity.
I have a regular text-box: <input type=text> I use jQuery to handle key-related events:
I have an input box which I want to handle two types of information,
i have one form which have some input box and some select box. i
I have a string value from a user input box. I have to figure
I have placed a form on a page which looks like this: <form id=editClassList
I have an input box which i use to add items to a table
Ok, so I have this search box in which people typein a food item.

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.