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 ?
This is commonly called a “placeholder,” and actually works in several browsers now.
Check out A Form of Madness: Placeholder Text:
And for browsers that don’t support it, here’s a JavaScript (jQuery) shim that will use that text to simulate the same effect: jquery-html5-placeholder-shim. If you include a reference to the shim, just add this to your JavaScript and you’re good to go.
As to the issue of localization, as long as you’re producing HTML with the correct information inside the
placeholderattribute you should be fine.