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 8111327
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T02:04:25+00:00 2026-06-06T02:04:25+00:00

i have the following problem with that code in my html tag: <div id=searchbar><input

  • 0

i have the following problem with that code in my html tag:

<div id="searchbar"><input name="searchbar" type="text" id="searchfield" value="some text" onfocus="
if(this.value==this.defaultValue) 
    this.value=''; 
    this.style.color='#11111'" 
onblur="
if(this.value=='') 
    this.value=this.defaultValue;
    this.style.color='#22222'
if(this.value==this.defaultValue) 
    this.style.color='#111111'" 

okay, the main goal is to approve that in my searchfield where the standard value is given with “some text” should change color for only new entries.

that message “some text” will disappear on click into it. now, the new value should change its color from standard #222222 to #111111. second, when leaving this field there have to be two different ways to look at. the first possibility should be that if the new value is different from the standard one with “some text” the color should stay on #222222. second possibility would be if the new entry is the same like standard value or even no entry was made then the color should change back to the default one to #222222. so the code above works up to the last point.

if there is someone who could give me advice on how to solve that i really would appreciate. thanks a lot.

  • 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-06T02:04:27+00:00Added an answer on June 6, 2026 at 2:04 am

    Instead of your long complicated code just use HTML5 placeholder

    Jsfiddle Example

    HTML

    <div id="searchbar">
    <input name="searchbar" type="text" id="searchfield" placeholder="Some Text" />
    </div>
    

    CSS

    #searchbar input {
        color: green;
    }
    input::-webkit-input-placeholder {
        color: red;
    }
    input:-moz-placeholder {
        color: red;
    }​
    

    Change the color according to your wish.

    Note: Placeholder will not support in IE.

    UPDATE

    If you wants to use a placeholder to support all browsers use this placeholder–a jQuery plugin and tweek the style.css in it to achieve your result.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have the following code that executes when a form submits: $('input[value=enter highlight]').val(''); Essentially,
I have the following html code <select id=WageBenifits_PayType name=WageBenifits.PayType> <option class=selectOption value= selected=selected>Please Select
I have the following problem with Tikz/Latex: I have some nodes that contain text.
I have a following problem, I have HTML form that uploads a file with
I have a following problem here: in my html structure I got some div's
I have the following html code. It works when using one H tag inside
I have the following HTML code: <div id=scroll> <div class=foo>foo1</div> <div class=foo>foo2</div> .... <div
I have a input type=file tag in my html which allows user to select
I have the following code for taking the html code of user selected text.
I have the following problem that the standard library doesn't solve well, and I'm

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.