views:

24

answers:

1

I've implemented this textbox watermark functionality on some of the text boxes in my solution:

http://cysemic.com/2010/03/jquery-textbox-watermark-revisited-making-it-a-plugin/

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?

+1  A: 

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.

Mauro
That's actually the best solution. The watermark filtering should happen client-side, as that's where they're being introduced. If the client has JavaScript to create the watermarks, it's safe to rely on JavaScript to filter them back out.
meagar