/    Sign up×
Community /Pin to ProfileBookmark

OnClick Clear Field

Hi there,
How can i clear the field of the value once the user has clicked in the field?

I.E when the user clicks inside the field, the value that is already in there is wiped clean… BUT if the USER has entered data then wants to edit it, not to clear the field… Compronde?

I have…
<input type=”text” size=”25″ name=”S_Name” value=”Second name”>

Fet

to post a comment
JavaScript

2 Comments(s)

Copy linkTweet thisAlerts:
@gil_davisJan 31.2007 — You can't have your cake, and eat it too.

How can you know if the user wants to edit what is there or put something else in it?

It may be best to leave well enough alone.
Copy linkTweet thisAlerts:
@sovikJan 31.2007 — for example:
<i>
</i>&lt;script&gt;
function foo() {
if (document.formname.S_Name.value=="Second name") {
document.formname.S_Name.value="";
}
}
&lt;/script&gt;

&lt;input type="text" size="25" name="S_Name" value="Second name" onfocus="foo()"&gt;

×

Success!

Help @scottyrob 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,
)...