How to prevent watermark text being sent when a button is clicked?
I've implemented this textbox watermark functionality on some of the text boxes in my solution:
It's very useful, but it's causing me some problems. Specifically, when I click the submit button when the watermark is present on a text box, the watermark text gets sent to the server. This means I have to do a test on the server to see if that text got sent, which isn't ideal.
could somebody suggest a client-side solution to this? So that when I click a button or a link which would normally end up bringing the text from the page to the server, that this is filtered out and nothing happens?
Propably not the best solution even (as I don't know what you're using on the server) but you may intercept the submit event and block the default behaviour (submit) if the value is empty or equal to the watermark text.
I think it would be better to place the watermark text by positioning it absolutely on top of the field you want to watermark. There is a plugin I developed called Watermarkify which does that. It also animates the watermark upon focus.