Implementing prompts in text-input

Posted by AntonAL on Stack Overflow See other posts from Stack Overflow or by AntonAL
Published on 2010-06-16T22:00:27Z Indexed on 2010/06/16 22:02 UTC
Read the original article Hit count: 131

Filed under:
|
|
|
|

Hi, I have a form with some text-inputs: login, password.

If user sees this form the first time, input-texts should "contain" prompts, like "enter login", "enter password".

If user clicks text-input, it's prompt should disappear to allow typing.

I have seen various examples, that uses background image with prerendered text on it.

Those images are appearing with following jQuery:

$("form > :text").focus(function(){
   // hide image
}).blur(function(){
   // show image, if text-input is still empty
   if ( $(this).val() == "" )
      // show image with prompt
});

This approach has following problems:

  • localization is impossible

  • need to pre-render images for various textual prompts

  • overhead with loading images

How do you overcomes such a problems ?

© Stack Overflow or respective owner

Related posts about JavaScript

Related posts about jQuery