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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T00:03:06+00:00 2026-06-04T00:03:06+00:00

I have an input field: <input name=Name value=Enter Your Name> How would I get

  • 0

I have an input field:

<input name="Name" value="Enter Your Name">

How would I get it to remove the pre-defined text (Enter Your Name) when the user clicks the box.

As far as I am aware Javascript is the best way to do this. If that wrong please inform me.

  • 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-04T00:03:07+00:00Added an answer on June 4, 2026 at 12:03 am

    HTML5 Placeholder Attribute

    You are likely wanting placeholder functionality:

    <input name="Name" placeholder="Enter Your Name" />
    

    Polyfill for Older Browsers

    This will not work in some older browsers, but polyfills exist (some require jQuery, others don’t) to patch that functionality.

    “Screw it, I’ll do it myself.”

    If you wanted to roll your own solution, you could use the onfocus and onblur events of your element to determine what its value should be:

    <input name="Name" value="Enter Your Name"
           onfocus="(this.value == 'Enter Your Name') && (this.value = '')"
           onblur="(this.value == '') && (this.value = 'Enter Your Name')" />
    

    Avoid Mixing HTML with JavaScript

    You’ll find that most of us aren’t big fans of evaluating JavaScript from attributes like onblur and onfocus. Instead, it’s more commonly encouraged to bind this logic up purely with JavaScript. Granted, it’s a bit more verbose, but it keeps a nice separation between your logic and your markup:

    var nameElement = document.forms.myForm.Name;
    
    function nameFocus( e ) {
      var element = e.target || window.event.srcElement;
      if (element.value == "Enter Your Name") element.value = "";
    }
    
    function nameBlur( e ) {
      var element = e.target || window.event.srcElement;
      if (element.value == "") element.value = "Enter Your Name";
    }
    
    if ( nameElement.addEventListener ) {
      nameElement.addEventListener("focus", nameFocus, false);
      nameElement.addEventListener("blur", nameBlur, false);
    } else if ( nameElement.attachEvent ) {
      nameElement.attachEvent("onfocus", nameFocus);
      nameElement.attachEvent("onblur", nameBlur);
    }
    

    Demo: http://jsbin.com/azehum/2/edit

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

Sidebar

Related Questions

I have a field that a user can input first and last name to
I have an input field whose name is an MD5 string e.g.: <input type=hidden
I have a form with two text_fields: <input type=text id=post_name name=post[name] /> <input type=text
I have an input field that is by default set to type=text so that
I have an input field which has a placeholder text. I want one word
I have an input field with the following value: 12-04-2012 This is a Dutch
I have an input field and I want to limit it to alphanumerical (A-Z,
I have an input field in a form. Upon pushing submit, I want to
I have an input field that uses Autocomplete to show a list of possible
i have an input field which will be displayed. i want that to hide

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.