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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T01:49:16+00:00 2026-05-26T01:49:16+00:00

I have simple routine to show tips in the textarea to the users. If

  • 0

I have simple routine to show tips in the textarea to the users. If the user focuses on the textarea and there is no user input, the script clears the tips. If the area is blurred without user inputs, the area shows the the tips.

This seems to work fine in IE and chrome, but firefox 3.6 does not seem to work every time.

Click the textarea to focus, the textarea clears the text

Don’t type anything and click outside to unfocus the textarea, the tip will show.

Click the textarea again to focus, but the text won’t disappear.

Click outside to unfocus

Click the textarea again to focus, this time the text area will clear the text.

Any tip or insight to correct this behavior for firefox 3.6?

JSFiddle link

TIA

<html xmlns="http://www.w3.org/1999/xhtml">
<head>            
 <script type="text/javascript" src="../jquery-1.6.4.min.js"></script>
</head>
<body >
<div style="text-align:center">
   <textarea id="btext"  onfocus="clearOnFocus()" onblur="showtip()">
Enter text
</textarea><br>
</div>
 <!-- end page -->
<script language="javascript">

function clearOnFocus () {
  //alert ('test');

  var patt=/Enter text/g;
  var result=patt.test($('#btext').val());
  if (result) {
    $('#btext').val('');
  }
}//end of clear

function showtip () {
  var textinput = $('#btext').val();

  if (textinput == '') {

  var btips = 'Enter text';

  $('#btext').val(btips);
    }
}//end of showtip

</script>
 </body>
</html>
  • 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-26T01:49:17+00:00Added an answer on May 26, 2026 at 1:49 am

    you can use a regular expression to test that the value is something other than just whitespace. You can also test against the default value to see if anything has beeen entered. That way your script is independent of the value of the textarea.

    <textarea onfocus="
      if (this.value == this.defaultValue) 
        this.value = '';
    "
    onblur="if (/^\s*$/.test(this.value))
      this.value = this.defaultValue
    ">Enter text</textarea>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have this simple regex replace based routine, is there anyway to improve its
I have a simple data layer routine that performs a password update, the user
Do you have a simple debounce routine handy to deal with a single switch
I have simple form. <form target=_blank action=somescript.php method=Post id=simpleForm> <input type=hidden name=url value=http://...> <input
I have simple HTML code with some JavaScript. It looks like: <html> <head> <script
I have a simple routine which calculates the aspect ratio from a floating point
I have a simple routine to find the next object based on a name
I have an windows application that performs a simple routine to determine whether a
I've got a simple routine that populates a record in a table. I have
I have a simple ASP.NET 3.5 SP1 Web Forms app... I've added the System.Web.Routing

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.