Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Text Fields in forms

Status
Not open for further replies.

Mark54321

Technical User
May 27, 2005
19
GB
Hello,

I have a question about text fields in forms.

Is there a simple way to create a text field with an initial value that automatically disappears once the reader starts to fill the field in? I can create the text field with the initial value - no problem there, just need the field to clear on use.

Thanks for any advice.

Mark
 
<input name="test" ... onFocus = "document.forms[0].test.value = ''">

<input name="email" type="text" id="email" value="Email" size="20">

The above is what I have, how do incorporate the top line into the second line?

I just want the word Email to appear in the field and then disappear once it is used.

Cheers,
Mark
 
Code:
<input name="email" type="text" id="email" value="Email" size="20" onFocus="document.forms[0].email.value = ''">

Just use this instead of what you already have

Cheech

[Peace][Pipe]
 
Thanks for your reply, but...

I used the code as you wrote it and it made no difference to the page. Nothing changed at all!

Is there another way to do this?

Cheers,
Mark
 
I used the code as you wrote it and it made no difference to the page. Nothing changed at all!

Then you havent done it correctly.
Code:
<html>
<body>
<br>
<form name="form1" method="post" action="">
<input name="email" type="text" id="email" value="Email" size="20" onFocus="value=''">
</form>
</body>
</html>
Copy and paste that into a new document and you will see it working

Cheech

[Peace][Pipe]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top