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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T15:34:36+00:00 2026-05-23T15:34:36+00:00

I am using the following script to add default values to input text boxes:

  • 0

I am using the following script to add default values to input text boxes:

$('.default-value').each(function() {
    var default_value = this.value;
    $(this).css('color', '#746F66'); // this could be in the style sheet instead
    $(this).focus(function() {
        if(this.value == default_value) {
            this.value = '';
            $(this).css('color', 'black');
        }
    });
    $(this).blur(function() {
        if(this.value == '') {
            $(this).css('color', '#746F66');
            this.value = default_value;
        }
    });
});

With the following form:

<form method="post" action="contactengine.php">
    <input type="textbox" class="default-value" name="Name" id="Name" value="Full Name">

    <input type="textbox" class="default-value" name="Email" id="Email" value="Email">

    <textarea name="Message" class="default-value" name="Message" id="Message" value="Your message"></textarea>

    <input type="submit" name="submit" id="submit" value="Submit" class="submit-button" />
</form>

The default values work fine for the textboxes, but I can’t work out how to get the default value into the textarea. At the moment nothing is showing up in the textarea, as you can see here.

Could someone help with this?

Thanks,

Nick

  • 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-23T15:34:36+00:00Added an answer on May 23, 2026 at 3:34 pm

    Try changing this line:

    var default_value = this.value;
    

    To:

    var default_value = $(this).val();
    

    This is because a textarea doesn’t have a value attribute, to assign a default text to this element simple place the text between the opening, and closing, tags of the element, as such:

    <textarea name="Message" class="default-value" name="Message" id="Message">Your message.</textarea>
    

    JS Fiddle demo.


    Edited after testing, in Chromium 12/Ubuntu 11.04, to discover that as far as JavaScript is concerned (at least for this browser/platform) var default_value = this.value; works to assign the default_value correctly.

    JS Fiddle demo.

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

Sidebar

Related Questions

I'm using the following JavaScript code: <script language=JavaScript1.2 type=text/javascript> function CreateBookmarkLink(title, url) { if
I am using the following script to close a contact panel: <script type=text/javascript> $(document).ready(function(){
I'm using the following jQuery plugins (along with the jQuery plugin): <script type=text/javascript src=scripts/jquery.scrollTo-min.js></script>
I am dynamically adding tabs to my page using the following script: var tabs
I'm using the following script in my website in order to create pagination next-previous
I'm using the following script to request new content to a file called index.html:
I'm using the following script to force a specific page - when loaded for
I have Divs show and hide (with an animation) using the following script (I
Ok, I have been using the following script for over a year now to
Using the following Webservice definition using aClientArgs as a complex type: [System.Web.Script.Services.ScriptService] public class

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.