im trying to use javascript in my textarea to display text until the user clicks on it. The text should show on load and disappear when clicked. However, mine seems to do the opposite. My text doesn't show on load until the user has clicked the box and clicked out of it again? not too sure what I've done wrong.
<form action="upload.php" method="POST">
<input type="hidden" name="hidden_id" value="<?php print $id; ?>"/>
<input type="text" id="username" name="sent_by" onfocus="if (this.value == 'Your Name')
this.value = '';" onblur="if (this.value == '') this.value = 'Your Name';" maxlength="30"
value="Your Name" />
<input type="text" id="user_email" name="sent_email" onfocus="if (this.value == 'Your Email')
this.value = '';" onblur="if (this.value == '') this.value = 'Your Email';" maxlength="30"
value="Your Email" />
<br /><br />
<textarea name="message" value="Enter Your Message Here..." cols="60" rows="5"
id="artical_message" onfocus="if (this.value == 'Enter Your Message Here...') this.value = '';"
onblur="if (this.value == '') this.value = 'Enter Your Message Here...';" ></textarea>
<p align="right">
<input name="submit_comment" type="submit" value="Send Message" class="contact_button">
</p>
</form>
textarea tags don't have value attributes. Try this: http://jsfiddle.net/kudTF/
Place the content inside the <textarea> tags.
<form action="upload.php" method="POST">
<input type="hidden" name="hidden_id" value="<?php print $id; ?>"/>
<input type="text" id="username" name="sent_by" onfocus="if (this.value == 'Your Name')
this.value = '';" onblur="if (this.value == '') this.value = 'Your Name';" maxlength="30"
value="Your Name" />
<input type="text" id="user_email" name="sent_email" onfocus="if (this.value == 'Your Email')
this.value = '';" onblur="if (this.value == '') this.value = 'Your Email';" maxlength="30"
value="Your Email" />
<br /><br />
<textarea name="message" value="Enter Your Message Here..." cols="60" rows="5"
id="artical_message" onfocus="if (this.value == 'Enter Your Message Here...') this.value = '';"
onblur="if (this.value == '') this.value = 'Enter Your Message Here...';" >Enter Your Message Here...</textarea>
<p align="right">
<input name="submit_comment" type="submit" value="Send Message" class="contact_button">
</p>
</form>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With