/    Sign up×
Community /Pin to ProfileBookmark

[RESOLVED] onfocus text disapears, on blur text reappears if nothing is typed in

Hello Everyone,

im trying to implement a login screen similar to Facebook. What i mean by this is i want the username and password fields to have text in them until the user selects the textfield. If the user does not type anything in the textfield the the onblur will automatically change it back, but if the user has typed something in then i want the text to be left alone.

At the moment the onblur always changes the value of the textfield. Im not sure how to solve this.

Any one have any ideas?

Thanks and Regards,
-Beano

(code i am using is below)

[code]
<input name=’username’ type=’text’ size=”10″ value=”username” onfocus=”this.value=”” onblur=”this.value=’username'”/>
<input name=’password’ type=’text’ size=”10″ value=”password” onfocus=”this.value=”” onblur=”this.value=’password'”/>
<input type=’submit’ name=’Submit’ value=’Login’ />
[/code]

to post a comment
JavaScript

2 Comments(s)

Copy linkTweet thisAlerts:
@FangJan 09.2010 — &lt;input name='username' type='text' size="10" value="username" onfocus="this.value=''" onblur="if(this.value==''){this.value=this.defaultValue;}"/&gt;
Copy linkTweet thisAlerts:
@BeanoEFCauthorJan 09.2010 — Thanks Fang

Regards,

-Beano
×

Success!

Help @BeanoEFC 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 5.18,
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: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

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

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...