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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T11:27:14+00:00 2026-06-07T11:27:14+00:00

How it is possible that during onfocus (on input field) input default value seen

  • 0

How it is possible that during onfocus (on input field) input default value seen like it is disabled but on input field could be written anything like default value isn’t exists ?

here is simple html =>

<input type="text" id="x">

and javascript =>

document.getElementById("x").onfocus = function(){
this.style.opacity = 0.5;
}

but I couldn’t do what I want.

  • 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-07T11:27:16+00:00Added an answer on June 7, 2026 at 11:27 am

    With “HTML5”, new functionality and attributes have been introduced for form-Elements (such as built-in form-validation for example)

    One of those is the placeholder – attribute. It shows a specified text on empty input-Fields that will be hidden, after a user starts to fill text in the field.
    The HTML-Markup looks like this:

    <input type="text" name="first_name" placeholder="Fill in your name">
    

    This feature is not supported by all browsers yet (you can check compatibility on caniuse.com

    In your code, you can check for compatibility with a simple function:

    var placeHolderSupport = ('placeholder' in document.createElement('input'));
    

    For older browsers, you would need to write a fallback JavaScript – Function, that reads this attribute and implement the behaviour yourselve. There are some blog-posts about this around the web, like one from David Walsh, that could help you with this.

    edit:

    I stumbled over this gist by Hagenburger (according blog-post), that should implement the behaviour you want to achieve for old browsers too. Note: it’s jQuery – code, not sure if you are using it, but even if not, it should give you an idea, what to do.

    So, given the compatibility – check from above:

    if(!placeHolderSupport){
        //gist code here (not sure if i'm allowed to copy this into my answer)
    }
    

    Like that, the native placeholder-implementation of the browser would be used, if it exists, otherwise, the JavaScript-function would take care of this.

    update 09/11/2012

    SO-User and Moderator ThiefMaster just pointed out a better and newer jQuery-plugin by Mathias Bynens, that already has built-in check for placeholder – support. Surely a better way to implement the placeholder-fallback than the gist I posted:

    jQuery Placeholder at github

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

Sidebar

Related Questions

What are the possible errors that can occur during memory allocation using malloc except
Is it possible that there are more than one certificate chain built during the
With at-rules, it's possible to have a ruleset for elements during that at-rule event
changing a static resource during runtine is something that sounds not possible. I have
It is quite possible that I may not have got the point, but I
It's possible that I'm not really understanding how git works here, but I have
I was wondering if its possible to change the default program class that gets
It is possible that my question title is misleading, but here goes -- I
I would like to know if it's possible that inside the main() function from
when a user logsout we are doing a session.invalidate(). But is it possible that

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.