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!

How to get rid of TEXT in a text box when the user starts typing

Status
Not open for further replies.

Guest_imported

New member
Jan 1, 1970
0

I have 2 text boxes which have values like "Email" and "Name". How can I make them dissapear the minute a user clicks on the appropriate field and starts typing his email address or name?

Thanks in advance.
 
<input type=&quot;text&quot; onfocus=&quot;if(this.value == &quot;name&quot;){this.value = ''}&quot; value=&quot;name&quot;> luciddream@subdimension.com
 
A fun little thing I like to do is the following:

<input type=&quot;text&quot; name=&quot;descriptive&quot; SIZE=&quot;40&quot; VALUE=&quot;Street / Neighborhood ...&quot; OnFocus=&quot;javascript: if (this.value == 'Street / Neighborhood ...') { this.value=''; } this.style.color='#000000';&quot; onBlur=&quot;javascript: if (this.value == '') { this.value='Street / Neighborhood ...'; } if (this.value == 'Street / Neighborhood ...') { this.style.color='#777777'; } else { this.style.color='#000000'; }&quot; STYLE=&quot;color:#777777;&quot;>

Sometimes I like the font color to change on the mouse rollover and go above and beyond..

<input type=&quot;text&quot; name=&quot;CouponCode&quot; value=&quot;optional&quot; size=&quot;7&quot; style=&quot;text-align: center; padding-right: 5px; padding-left: 5px; color:#444444; height:22px; background-color:#ffffff; border:1px solid; border-color:#777777; border-top-width: 2px; border-left-width: 2px;&quot; onFocus=&quot;javascript: if (this.value == 'optional') { this.value=''; } this.style.color='#000000';&quot; onBlur=&quot;javascript: if (this.value == '') { this.value='optional'; } if (this.value == 'optional') { this.style.color='#444444'; } else { this.style.color='#000000'; }&quot; onMouseOver=&quot;if (this.value == 'optional') { this.style.color='#332222'; }&quot; onMouseOut=&quot;if (this.value == 'optional') { this.style.color='#444444'; }&quot;>

Andrew
 
I hate it when that happens. Looking through old threads and respond to one of them..

[mad]

Andrew
 
<form>
<input
type=&quot;text&quot;
value=&quot;Name&quot;
size=&quot;10&quot;
onfocus=&quot;if(this.value=='Name') {this.value='';}&quot;
>
<input
type=&quot;text&quot;
value=&quot;Email&quot;
size=&quot;10&quot;
onfocus=&quot;if(this.value=='Email') {this.value='';}&quot;
>
</form> ---------------------------------------
wmail.jpg


someone knowledge ends where
someone else knowledge starts
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top