Wayne:

> I'm trying to prompt for input within the field using the Example
> plugin (http://plugins.jquery.com/project/example). The idea is that
> I'm styling my input field to be unsually large when the user types
> (it will be no more than a 4 or 5 digits), so I can use closer to
> normal size text as the prompt.
>
> I know I can do this with a textarea, but it's semantically incorrect,
> and using the return key creates a new line. I don't want to shoehorn
> the simple input into a textarea, but I want the prompt to be
> meaningful, like "Enter a measurement for this baseline," instead of
> "type here" or whatever short message I could use. I also like the
> amount of space that it takes up visually with two lines.
>
> What is a better way of doing this? Should I just use a jEditable
> element and style it to look like a form input?
>

Why not just use an <input /> element? Use CSS to give it a transparent
background and other styles you want and then place a <div /> with a lower
z-index underneath with the label. I think maybe this plug-in does that:

http://plugins.jquery.com/project/overlabel

(But it might just be replacing the text in the field--the site is down at
the moment.)

If you do something like the following, then you can position the label
underneath:

<div style="position: relative;">
  <input type="text" style="font-size: 32px; background-color: transparent;
z-index: 2;" />
  <div id="underlabel" style="position: absolute; z-index; 1;">Your label
here...</div>
</div>

You'll need to set the "underlabel" <div /> to the dimensions of the <input
/> element, but then you should be able to use CSS to control everything
else about the layer. You can then just show/hide the "underlabel" based
upon whether or not the field has focus.

-Dan

Reply via email to