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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T10:33:04+00:00 2026-06-13T10:33:04+00:00

When a textbox is created, default, gray text (#888) is given a displayed. When

  • 0

When a textbox is created, default, gray text (#888) is given a displayed. When it is given focus, the value should disappear and start showing the typed value. I’ve written the code for this problem and it is as follows:

<html>
    <script type="text/javascript">
        function Focus(i) {
            if (i.value == i.defaultValue) {
                i.value = "";
                i.style.color = "#000";
            }
        }

        function Blur(i) {
            if (i.value == "") {
                i.value = i.defaultValue;
                i.style.color = "#888";
            }
        }
    </script>

    <body>
        <input type="text" name="enter firstname" title="First Name" style="color:#888;"
        value="First Name" onfocus="Focus(this)" onblur="Blur(this)" />
        <input type="text" name="enterlastname" title="Last Name" style="color:#888;"
        value="lastname" onfocus="Focus(this)" onblur="Blur(this)" />
    </body>

</html>

But, here whenever the textbox is focused, the value is disappearing. What should I do in order to correct this? Even though the text box is under focus, the value should not disappear and the value should disappear only when I start typing in it. I’m a new user so I can’t post screenshots.

  • 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-13T10:33:06+00:00Added an answer on June 13, 2026 at 10:33 am

    what you want is called placeholder.

    use it like this:

    <input type="text" name="enterfirstname" placeholder="First Name" />
    <input type="text" name="enterlastname" placeholder="Last Name" />
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Is it possible to add a default text value to a TextBox in WPF,
I want to create a TextBox, which would have a gray default text appear
In the default newly created MVC3 application, at the CRUD's Create view, the text
I created a simple jquery plugin that puts 'greyed out' text into a textbox
I have created a TextBox control in DocumentViewer 's Toolbar for displaying the current
I created a AutoCompleteExtender on a TextBox that resides on a UserControl (Control.ascx file).
I created my own custom date picker consisting of an ASP TextBox, Button, and
I created a form with a label, textbox and a button. In the form
I have created an ASP.NET class derived from the standard WebControls.TextBox , with the
I have a textbox in a form that I created. I want to add

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.