PDA

View Full Version : Form Click Clearing



Christov
December 8th, 2006, 08:03 AM
Was just wondering if anyone could direct me to some help with a form.
I've seen it done on various websites where a text field has some initial text on it which is cleared when the user clicks into the box to input their own text.
If anyone knows how to do it and shows me or links me to a tutorial I'd be most grateful :)

Thanks in advance !

Christov
December 8th, 2006, 08:29 AM
Sorry to double post: http://www.pixel2life.com you can see the effect on the Username / Password fields at the very top of the page on the right.

aldomatic
December 8th, 2006, 09:34 AM
um just give it a value attribute like value="type here"

Christov
December 8th, 2006, 09:44 AM
No, I mean when I click it the text is still there - i want it to disappear when its clicked on.

aldomatic
December 8th, 2006, 09:56 AM
add that to the input tag for the input box



onclick="if (this.value == 'something') { this.value = ''; }" onblur="if (
this.value == '') { this.value = something'; }"

Christov
December 8th, 2006, 10:29 AM
Brilliant ! for some reason the old text doesnt come back when I click off it, even though I've defined it, but I can live with that :) Thanks mate !

aldomatic
December 8th, 2006, 10:59 AM
:beer:

aldomatic
December 8th, 2006, 11:02 AM
oh at the end i forgot an ' before "something" so add it and i think that might fix that problem

edited:


onclick="if (this.value == 'something')
{ this.value = ' '; }"

onblur="if (this.value == ' ')
{ this.value = 'something'; }"