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 gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

text box with initial value 3

Status
Not open for further replies.

balance

Programmer
Feb 5, 2002
52
CA
Hello,

I am looking for a way to have a text box with an initial value in it. I know you can do this by stating and initial value...but I am looking for the inital value to disappear once they click in the box.

For example, if I have a text box called email I might look for it to say yourname@yourdomain.com, then when the user clicks on the box it will erase that value allowing them to put their email address.

Any help or references is greatly appreciated.

Thanks

AJ
 
This should do it.

<input type=&quot;text&quot; value=&quot;hello&quot; onfocus=&quot;this.value=''&quot;>

Cheers,

Tom
 
You could try the following, but I haven't tested any of it.

--------------------------------------------

<SCRIPT LANGUAGE=&quot;JavaScript&quot;>
function EmailOnClick()
{
if (document.forms.FormName.txtEmail.value == 'yourname@yourdomain.com')
{
document.forms.FormName.txtEmail.value = '';
}
}
</SCRIPT>

<INPUT TYPE=&quot;TEXT&quot; NAME=&quot;txtEmail&quot; VALUE=&quot;yourname@yourdomain.com&quot; ONCLICK=&quot;EmailOnClick();&quot;>

-------------------------------------------------

- Bill Davis
 
here it is:

<form name=someform>
...
<input type=&quot;text&quot; name=&quot;something&quot; value=&quot;yourname@yourdomain.com&quot; onfocus=&quot;this.value='' &quot;>
...
</form>

Works in all browsers.
good luck

 
All three of you are awesome, thanks for the info.

Have a great weekend!

AJ
 
Good answers! You should give them a star! Tracy Dryden
tracy@bydisn.com

Meddle not in the affairs of dragons,
For you are crunchy, and good with mustard. [dragon]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top