|
Posted by Jukka K. Korpela on 12/16/06 16:52
Scripsit nice.guy.nige:
> While the city slept, Olli Mäntyranta (ollimax@gmail.com) feverishly
> typed...
>
>> sally jo wrote:
>>> What is the code that you use to put words int he input box that
>>> disappear when the user starts typing??
> [...]
>> function ClearText(){
>> document.theBigForm.theField.value = "";
>> }
> [...]
>
> The only problem with this code is that it will clear the textbox
> everytime it is clicked on.
No, the problem is that it sometimes "works". Therefore it lets the author
preserve the impression of being clever and doing the right thing. Well, it
also wipes our user input, of course, at times.
> if(firstTime) {
> document.theBigForm.theField.value = "";
> firstTime = false;
> }
It does not help against the problem that the user starts typing and then
the JavaScript code starts executing and kills his input. Of course, if the
author is slow in typing, he never realizes this.
So the clue is that the original idea, which creates the problem, should be
abandoned. Do _not_ put any initial content in a textfield, unless it is a
meaningful default, and then you surely don't want to remove it when the
user focuses on the field.
Instead, use meaningful labels and, if needed, explanations - before the
textfield.
--
Jukka K. Korpela ("Yucca")
http://www.cs.tut.fi/~jkorpela/
[Back to original message]
|