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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T17:47:42+00:00 2026-05-26T17:47:42+00:00

I would like to know how to implement something like stack overflow when you

  • 0

I would like to know how to implement something like stack overflow when you post a question: “At least one tag such as (css html asp.net), max 5 tags.

How can I implement something like this for a text input in html, where it is partially faded, but when you type, it doesn’t show up, and is not faded.

I don’t mind how to do this, as long as it works.

Thanks.

  • 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-26T17:47:43+00:00Added an answer on May 26, 2026 at 5:47 pm

    The easiest option is to use the placeholder attribute:

    <input type="text" placeholder="At least one tag, such as 'html', 'asp.net', max five tags." />
    

    JS Fiddle demo.

    If cross-compatibility is a requirement, then JavaScript is also an option:

    var inputs = document.getElementsByTagName('input');
    
    for (i=0; i<inputs.length; i++){
        if (inputs[i].hasAttribute('data-hint')){
            inputs[i].value = inputs[i].getAttribute('data-hint');
                inputs[i].style.color = '#999';
    
            inputs[i].onclick = function(){
                this.value = '';
            };
            inputs[i].onblur = function(){
                if (this.value == '' || this.value == this.getAttribute('data-hint')){
                    this.value = this.getAttribute('data-hint');
                    this.style.color = '#000';
                }
            };
        }
    }
    

    JS Fiddle demo.

    Or, with jQuery:

    $('input:text').each(
        function(){
            $(this).val($(this).attr('data-hint'));
                $(this).css('color','#999');
        }).click(
        function(){
            $(this).val('');
                $(this).css('color','#000');
        }).blur(
        function(){
            if ($(this).val() == ''){
                $(this).val($(this).attr('data-hint'));
                $(this).css('color','#999');
            }
        });
    

    JS Fiddle demo.

    References:

    • Common Input Element Attributes (W3.org).

    Vanilla JavaScript:

    • document.getElementsByTagName().
    • element.onblur.
    • element.onfocus.
    • element.hasAttribute().
    • element.getAttribute().
    • element.style.

    jQuery:

    • text-input (:text) selector.
    • .each().
    • .val().
    • .css().
    • .attr().
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm making an app for fun and would like to know how to implement
I'm new to Zend Framework. I would like to know how to implement zend
I would like to know how to efficiently implement filesystem changes in java? Say
I would like to know how to implement a URL slug functionality in a
I would like to know if we have something in XSL 2.0, equivalent to
I would like to know are there something already available in Java, which will
I would like to know how should I implement a count down timer in
I would like to know if an instance implements a specific method. I could
I would like to know how a set is implemented in C++. If I
i would like know some reference. I know i can googling it. but prefer

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.