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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 19, 20262026-05-19T02:30:42+00:00 2026-05-19T02:30:42+00:00

I have an input field that asks for an email address followed by a

  • 0

I have an input field that asks for an email address followed by a submit button. Here is the code associated with that:

HTML

<div class="email">

    <form action="handler.php" method="post" id="hgb-signup">
    <input type="text" name="email" id="email" value="Enter your email address">
    <input type="submit" name="submit" id="submit" value="&raquo;" />
    </form>

</div>

JAVASCRIPT

Event.observe(window, 'load', function() {
    jQuery('#email').focus(function() {
        jQuery(this).val('');
    });
    jQuery("#hgb-signup").submit(function(e){
        var dataString = jQuery(this).serialize();
        jQuery('#email').val('Sending... please wait...');
        jQuery.getJSON('handler.php?callback=?', {
            "sent_data": dataString }, 
            function(received_data) {
                jQuery('#email').val(received_data.message);
            }
        );
        e.preventDefault();
    });
});

Right now, when the page loads the #email input field reads “Enter your email address”. When you click on the submit button, it overwrites the #email value with “Sending… please wait…” and depending on whether there’s been a problem or the submission was successful, there will be a respective message inside the #email field indicating such. Now, when I click inside the input field, the “Enter your email address” text disappears .val(''), and when I click outside the field, that message is still gone. I initially had a .blur() that put the message back, which is the desired result, however, when users would enter their email address and hit submit, it would submit “Enter your email address” and not the actual email address, because when you hit the submit button .blur() was called.

Now knowing what the goal is, is there a .blur() alternative and if not, how do I best handle this situation?

Basically, here’s what I’m looking for:

The #email field should read “Enter your email address” at any given time when the cursor is not inside the field and should come back when the cursor leaves the field, but I would like the error/success message to stay in there after the form has been submitted, unless the user clicks back inside the field and leaves, then it can say “Enter your email address” again.

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-19T02:30:43+00:00Added an answer on May 19, 2026 at 2:30 am

    Use .blur(), but check the val() first. Replace with "Enter your email" only when it’s empty

    jQuery('#email').blur(function() {
        var $this = jQuery(this);
        if ($this.val() == '') $this.val('Enter your email');
    });
    

    Here’s a jsfiddle for you, you can check it out. I also added a check to focus() handler so it would not remove contents when you click on an input field after entering your email.

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

Sidebar

Related Questions

I have an input field that is appended to the HTML in a div.
I'm trying to have a comment input field that will show the submit button
I have an input field with an id that is used as a button.
I have an input field that is rendered with a template like so: <div
I have this field that asks for a date in an iPhone HTML App:
Update is below code chunks. Original Question: I have an input field that is
I have an input field that is appended to a div tag through a
I have an HTML input field that I want the user to be able
I have an input field that is by default set to type=text so that
I have an input field that uses Autocomplete to show a list of possible

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.