/    Sign up×
Community /Pin to ProfileBookmark

Form action On Focus problem ?

On this page’s mail form:
[URL=http://www.xn3ct.net/SampleSite04/contact.html]http://www.xn3ct.net/SampleSite04/contact.html[/URL] I want the viewer to be able to see [B]Type e-mail address[/B] and [B]Type Message for Mike[/B] as one opens the page, right away. Right now, [B]Type e-mail address[/B] appears at first, however the bottom text doesn’t appear in the [COLOR=Navy]text field[/COLOR], until I click on it and click away from it… then, it appears.

Here’s the code:

[code=php]
<form action=”contact.php” name=”ContactMe” method=”post” target=”_top”>
<input type=”hidden” name=”recipient” value=”[email protected]”/>
<input name=”Email” type=”text” id=”email” form size=”25″ style=”font-family: Verdana, sans-serif; color: gray; border:1px dashed #00FFFF;”
value=”Type e-mail address” size=”25″ onfocus=”if (this.value==’Type e-mail address’){this.value=”;};return false;”
onblur=”if (this.value==”){this.value=’Type e-mail address’;return false;}”>
<br><br>
<textarea name=”ContactText” cols=”38″ maxlength=”3″ rows=”3″ form=”form” style=”font-family: Verdana, sans-serif; color: gray; border:1px dashed #00FFFF;”
value=”Type message for Mike” size=”25″ onfocus=”if (this.value==’Type message for Mike’){this.value=”;};return false;”
onblur=”if (this.value==”){this.value=’Type message for Mike’;return false;}”>
</textarea>
<input name=”Contact” type=”submit” id=”Submit2″ value=”Contact”>
</form>
[/code]

to post a comment
JavaScript

5 Comments(s)

Copy linkTweet thisAlerts:
@cclMar 17.2006 — <textarea> tag does not have a value attribute.

Put your text "Type message for Mike" between the opening and closing tags

<textarea>Type message for Mike</textarea>

You are going to have a problem with your validation too, but I'm not sure how to check for input in a <textarea>
Copy linkTweet thisAlerts:
@phpnoviceMar 18.2006 — You are going to have a problem with your validation too, but I'm not sure how to check for input in a <textarea>[/QUOTE]
It is true that the HTML for the TEXTAREA element does not have a [b]value[/b] [U]attribute[/U]. However, the DOM [B][I][U]does[/U][/I][/B] have a [b]value[/b] [U]property[/U] for the TEXTAREA object and for JavaScript's use. That is how you would validate it.
Copy linkTweet thisAlerts:
@jamesx521authorMar 28.2006 — When I remove "Type message for Mike" from [B]value=[/B] and put it in between [B]<textarea></textarea>[/B] the text appears, however when I click on the text box, it doesn't disapear... I have to manually delete it. What other options do I have?
Copy linkTweet thisAlerts:
@phpnoviceMar 28.2006 — When I remove "Type message for Mike" from [B]value=[/B] and put it in between [B]<textarea></textarea>[/B] the text appears, however when I click on the text box, it doesn't disapear... I have to manually delete it.[/QUOTE]
Works fine for me. Make sure that you arrange it this way -- all on one line:

...>Type message for Mike</textarea>
Copy linkTweet thisAlerts:
@jamesx521authorMar 28.2006 — Works fine for me. Make sure that you arrange it this way -- all on one line:

...>Type message for Mike</textarea>[/QUOTE]


Thanks; That's what it was. It's ok now.

http://www.xn3ct.net/SampleSite04/contact.html

Except... I don't know why the initial [I]"Type message for Mike"[/I] text appears larger on [B]Mozilla[/B], not on [B]IE[/B].
×

Success!

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