tags:

views:

32

answers:

3

Two semi-related questions:

1) I've seen <input> and <textarea> boxes that contain some default text, like "enter search terms here", and the moment you click on the box, the text disappears. How is this implemented? Is this a Javascript thing?

2) Can the default text be in one color, and whatever you type (either overwriting, or appending), be in a different color?

+1  A: 

1) They're called input watermark. You can find a lot of jquery plugins for doing that. This is one of them

2) You can control watermark text using css

Now, If you allow me, I have one question for you: you've made 5 questions here on SO, getting back 19 answers and 11 votes that have created your reputation without never accepting any answer. Dont you think it's time to fix this?

Cheers, Lorenzo

Lorenzo
A: 

This is a good simple example:

<style type="text/css">

textarea {color:blue;}

</style>

<html>
<head>
<title>TextArea Position Handling Test</title>
</head>
<body>
<center>
  <textarea style="position: relative"> Insert the watermark text here!</textarea>
</center>
</body>
</html>

Good luck!

(No jQuery) :)

Trufa
A: 

I wrote a jQuery plugin for that.

Usage

$(document).ready(function() { 
  $('#my-form input.first-name').inputLabel({ defaultLabel: 'enter your first name bozo' });   
});
alex