/    Sign up×
Community /Pin to ProfileBookmark

Hi,

What script can I use that, when a text field is click on, the value text disappears and when someone clicks put of the text field, the value text comes back?

Thanks,
BOB101

to post a comment
CSS

2 Comments(s)

Copy linkTweet thisAlerts:
@The_Little_GuyFeb 18.2006 — I can't find one that make it reapper after you click some where else and it comes back, but this will show text until you click on the feild. Here is an example: http://dumbells.t35.com/hunter/cluehunter.php

There is 3 parts to this code, The JavaScript (within the head):
[CODE]<SCRIPT type="JavaScript">
<!-- Begin
function placeFocus() {
if (document.forms.length > 0) {
var field = document.forms[0];
for (i = 0; i < field.length; i++) {
if ((field.elements[i].type == "text") || (field.elements[i].type == "textarea") || (field.elements[i].type.toString().charAt(0) == "s")) {
document.forms[0].elements[i].focus();
break;
}
}
}
}
// End -->
</script>[/CODE]

The Body:
[CODE]<body OnLoad="placeFocus()">[/CODE]
And the Text Feild:
[CODE]<input name='answer' value='Type Answer Here!' onfocus='if(this.value=="Type Answer Here!")this.value="";' type='text'>[/CODE]
Copy linkTweet thisAlerts:
@ray326Feb 18.2006 — Why do you want the old text to come back other than the fun of pissing off your visitors?
×

Success!

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