开发者

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:

http://cysemic.com/2010/03/jquery-textbox-watermark-revisited-making-it-a-plu开发者_Python百科gin/

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.

Demo : http://www.ajaybalachandran.com/demo/watermarkify/

Download : http://www.ajaybalachandran.com/blog/48/watermarkify-jquery-twitter-like-animated-textfield-watermarks/

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜