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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T01:43:12+00:00 2026-05-23T01:43:12+00:00

When I click inside the input fields the values Email and password disappear which

  • 0

When I click inside the input fields the values “Email” and “password” disappear which is what I want. But if the user doesn’t enter his email/pass and clicks somewhere else, I want “Email” and “Password” to reappear.

jQuery:

$('.login-user, .login-pass').focus(function() {
    $(this).val("");
  });

Html:

<input type="text" name="user" value="Email" tabindex="1" class="login-user" />
<input type="password" name="password" value="Password" tabindex="2" class="login-pass" />

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-23T01:43:13+00:00Added an answer on May 23, 2026 at 1:43 am

    Update:

    I finally got around to doing a dead-simple plugin for supporting the placeholder attribute on browsers that don’t do it natively. Been planning to for a long time, and I have a project that needs it, so… place5 (the plugin) auto-detects native support and leaves things alone (by default) on browsers that can do the job themselves (although you can override that if you really want to use the plugin instead).


    Original answer:

    I’d probably do it as a plug-in I could reuse, but basically, since you’re dealing only with inputelements, it can be quite simple:

    $(".login-user, .login-pass").each(function() {
        $(this)
            .focus(function() {
                if (this.value.length === this.defaultValue) {
                    this.value = "";
                }
            })
            .blur(function() {
                if (this.value.length === 0) {
                    this.value = this.defaultValue;
                }
            });
    });
    

    That uses the defaultValue of the input element to set the value if the value is blank when the user leaves the field, and to clear the value when the user enters the field if it’s the default value. This assumes you use value="placeholder to show" in your markup.

    A more thorough solution would use the new placeholder attribute and use feature-detection to see whether it was supported (which it sadly isn’t in IE, and even in Firefox 3.6 but I bet 4.0 has it). I keep meaning to do something up…

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

Sidebar

Related Questions

I want to reveal a div with an input inside when you click a
I want to have a JEditorPane inside a JScrollPane. When the user clicks a
I want to put a form with input field and submit button inside a
My textarea is behaving very strange, when I click inside it .. the cursor
<div id=container> <div id=son1> </div> <div id=son2> </div> </div> When click inside container or
i have Linkbutton inside updatePanel and when i click on it it returns following
i have a click event for $('#blah div'). div has text inside of it
I have a JList inside a Scrollpane. If you click on the list and
In my application I have a UITextField inside a UITableViewCell . If I click
I have a piece of code that clones three fields, but when it clones

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.