Hello Forum,
This is my first post, I have been using query for about a week, so I am very new.
I have a form I have made where I want Jquery to add a watermark to a couple of textboxs. I can do it, but I have a couple of problems
1) currently I need to repeat the code (once for each textbox)
2) It has a dependency on the HTML
$("#requirements").focus(function () {
if ($(this).val() == "Enter any extra requirements here....")
$(this).removeClass("watermark").val('');
}).blur(function () {
if ($(this).val() == '')
$(this).addClass("watermark").val("Enter any extra requirements here....");
});
Problem 1 - How can I apply this to both textboxes,
Problem 2 - This is dependent of me setting the text default value in the HTML to the same currently "Enter any extra requirements here...."
I release these two problems are related as the 2nd problem has to be resolved first, and the watermark text is not the same for both boxes.
I was trying to sort this out by saying something like
if ($(this).val() == {name field in HTML of text box}
)
if ($(this).val() == "Enter any extra requirements
here....")
This way the default values would not be in Jquery but in the HTML, then it makes it easier to fix problem one.
I am so new to Jquery I dont know really where to start :-) - Any help would be great
Thank you
Graham