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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T15:45:52+00:00 2026-06-03T15:45:52+00:00

Is there any way to detect in javascript, if the following html5 or css

  • 0

Is there any way to detect in javascript, if the following html5 or css 3 feature is available on a browser.

for example, i have an attribute : placeholder,

<input type="text" placeholder="type your email address" />

i set a javascript function, that would set a manual placeholder, if placeholder attribute is not supported by the browser


if i use Modernizr, would this do :

if ( Modernizr.testProp('placeholder') )
// add attribute placeholder
else
// assign a keypress event as placefolder
  • 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-03T15:45:55+00:00Added an answer on June 3, 2026 at 3:45 pm

    In a simple case like this, you can do things directly without involving Modernizr:

    <input type="text" placeholder="type your email address" 
      id="email">
    <script>    
    var email = document.getElementById('email');
    if(!('placeholder' in email)) {
      email.value = email.getAttribute('placeholder');
      email.onfocus = function () { this.value = ''; };
    }
    </script>
    

    In this approach, the placeholder attribute appears in static HTML markup. It does no harm when not supported; in fact, it can even be useful when not supported.

    The point is that when placeholder is supported, a property with that name exists for the element node. Even when it is not supported, the browser has parsed and stored it, so that you can get it with getAttribute() and assign the value to the value property, to make it appear as the initial content.

    The code clears the field when focused. This sounds better than clearing it whenever clicked on, as the user might click on the field for several reasons after typing part of the data.

    P.S. For usability, accessibility, and simplicity, it is better to use a visible label for every input field, instead of using placeholders. So this does not like a good use case. But the same technique can be used e.g. for a very simple search form that sites often have as part of site-wide navigation system; there it can make sense to squeeze the form to a very small size, omitting labels.

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

Sidebar

Related Questions

Is there any way to detect when classes have changed during run-time with Hotswap?
Is there any way that I can detect browser type on routing and use
Is there any way to detect the current keyboard layout using JavaScript? I found
Is there any way, via C# code, to detect whether JavaScript is enabled or
Is there a way to detect via JavaScript (client side) any AJAX requests that
Is there a way (in JavaScript) to detect between the following two scenarios? Device
Is there any way possible to detect if a user has disabled JavaScript after
Is there any way I can detect the support for rel=noreferrer with Javascript? <a
I'm wondering wether there's a Javascript way to detect wether a user has any
Is there any way to detect IE7? I don't have any problems with my

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.