View Full Version : text input field behaviour

03-11-2009, 02:22 PM
Hey guys,

here is my problem. I have a form with meny input fields. As initial value I have: Type your name here. Once I have the page live, the field text needs to be deleted for the user to type his/her name. What I have seen and I want to do is to have the initioal value as is but when the user clicks on the text field to fill in the inital value disapears.

I hope it is clear enough...if not please let me know,

Thanks in advance,


03-12-2009, 01:25 AM
found this , havent tried it though

<script language="Javascript">

function Clear(Text) {
if (Text.value == Text.defaultValue)
{ Text.value = ""
<input type="text" size=15 value="Enter name" onFocus="Clear(this)">

03-12-2009, 01:38 AM
this maybe better

03-12-2009, 11:06 AM
that removes the text but if you move away from the field the field stays empty

what you need is to detect when blank and then reinsert the original text (label)

03-12-2009, 03:18 PM
EDBR, Thanks for the code. It works fine for what I need.

The page I have is full of promotional Items available only to distributors. The page shows the prices those items are offered to them and the distributors can put on those fields their own marked up prices. So, they have to click on each input field and add a price.

So far so good. Thanks again.

DavidJ, I must admit that I'm just a hack with javascript and as such it takes me a very long time to write anything. However, if you have a tutorial to the technique you have in mind, please let me know.