View Full Version : Javascript Input boxes: PLEASE HELP

09-22-2005, 03:36 PM
Hi everyone,

Of all the web languages, javascript is probably my worst and I was wondering if i could get some help with what i think should be pretty simple.

I would like to make my login input boxes show a value when not selected, clear themselves when they are, and then return to the old value when they are left. I have managed to get the text to dissappear using this,


but I'm not sure how to get the text to return if i click elsewhere in the page. Any help would be great.


09-22-2005, 03:57 PM
You do realize that doing this will mean the user entered value will never be submitted, right? Since by definition, form submit will make the box lose focus (user clicks submit button, image, or presses enter key).

Are you sure the page element you want is a textbox?

Anyway, onBlur is the event you're looking for.

09-22-2005, 04:23 PM
thanks for your help Nikki. In response to your question, beacuse the if statement checks the value inside each input box, the value only dissappears when it is equal to the initial value.

works great, thanks!