Web Hosting Talk







View Full Version : JavaScript Question ...


KIA-Joe
09-10-2004, 11:58 AM
I can't find this any where but I know I have seen it.

I am assuming its done with JS ...

How do you make text in an input field in a form disappear??

Like if I had in a field "type your email address here" and when they click it it goes away automatically.

Thanks for your help!!

effusionx1
09-10-2004, 12:03 PM
<input type="text" name="textfield" onClick=cleartext();>


<script language="Javascript">
function cleartext
{
textfield.value = ""
}
</script>

effusionx1
09-10-2004, 12:12 PM
Hope that helps

armstrongecom
09-10-2004, 01:22 PM
That works, but I've also used...

<input type="text" name="fieldname" value="Your email here" onFocus="javascript:this.value='';">

KIA-Joe
09-10-2004, 03:21 PM
That didn't work for me for some reason ... but the second suggestion did.

Thanks a bunch!

MilesToGo
09-11-2004, 04:23 AM
I know you already have your answer, but I wanted to say that you don't need the javascript: part of that example. While I'm making suggestions, I'd recommend only clearing the text if it's the default.

Something like:

<input type="text" name="fieldname" value="Your email here" onFocus="if(this.value=='Your email here')this.value='';">