deleting textarea values from a form
Hello,
I have a simple, three-field form that I am setting default values from within my jquery script. When a user clicks on a field the default values are removed, leaving that field blank for the user to type into.
The form accepts the default values from my jQuery script just fine. And when I click on the "to" and "from" fields, the default text is, in fact, removed.
The problem is when I click on the textarea, the default value does not get removed.
Any thoughts?
Here is my html:
- <form class="blogForm" name="blogForm">
- <Input class="blogFormTo" type="text" name="email" />
- <Input class="blogFormFrom" type="text" name="email" />
- <textarea class="blogFormNote"></textarea>
- </form>
And my jquery:
- $(document).ready(function()
- {
- // clear form field values on click
- // set default values
- $(".blogFormTo").val("To: (Separate multiple addresses with commas)");
- $(".blogFormFrom").val("From: (Enter email address)");
- $(".blogFormNote").val("Add a personal message");
-
- // clear the "to" field if value is default
- $(".blogFormTo",this).click(function()
- {
- if (this.value=="To: (Separate multiple addresses with commas)")
- {
- this.value = "";
- }
- });
- // clear the "from" field if value is default
- $(".blogFormFrom",this).click(function()
- {
- if (this.value=="From: (Enter email address)")
- {
- this.value = "";
- }
- });
-
- // clear the "text" field if value is default
- $(".blogFormNote",this).click(function()
- {
- if (this.value == "Add a personal message")
- {
- $(this).value = "";
- }
- });
- });
Thanks!
nucklebone