/    Sign up×
Community /Pin to ProfileBookmark

javascript form field value

On my website, gayeventsguide.com, I have a place to signup for my newsletter at the top right.

In the form field it says “Enter Email”

How do I create a javascript that once the focus is placed inside the box it will remove the “Enter Email” statement?

Thanks
Jacob

to post a comment
JavaScript

3 Comments(s)

Copy linkTweet thisAlerts:
@gphOct 19.2005 — <i>
</i>&lt;input type="text" onfocus="this.value='';this.onfocus=null" value="Enter Email"&gt;
Copy linkTweet thisAlerts:
@planeboy747authorOct 19.2005 — perfecto! Thanks...here's next question, if focus is taken off the field, then it doesnt put "Enter Email" back in the box, how do I do that?
Copy linkTweet thisAlerts:
@gphOct 19.2005 — now you need functions

<i>
</i>&lt;script type="text/javascript"&gt;

function input_onfocus(el){
el.value='';
el.onfocus=null
}

function input_onblur(el){
el.value='Enter Email';
el.onfocus=function(){
input_onfocus(this)
}
}

&lt;/script&gt;

&lt;/head&gt;
&lt;body&gt;


&lt;input type="text" onfocus="input_onfocus(this)" onblur="input_onblur(this)" value="Enter Email"&gt;
×

Success!

Help @planeboy747 spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 6.2,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @meenaratha,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,

tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,
)...