Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

chainprayer

macrumors 6502a
Original poster
Feb 10, 2008
638
2
I'm trying to get a text field in an HTML form that has a default value (i.e. it says email address) but when a user clicks on it the form clears.

I know how to make a default value, but the user has to manually clear the default before entering their info.

Thanks!
 
Javascript. Try this.

Code:
onFocus="this.value=''"

So it would look like this:

Code:
<input type="text" onFocus="this.value=''" value="Email address here">
 
Optionally, you can have it re-add the default text if the user hasn't entered anything:

Code:
<input type="text" onFocus="this.value='';" onBlur="if(this.value=='') {this.value='Email Address here';}" value="Email address here" />
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.