views:

70

answers:

2

Hi Guys,

I have a problem in that I am using a simple watermark plugin such that it works

jQuery('#selector').Watermark('Watermark text here ...');

The problem is - when I try and use something like

if (jQuery('#selector').val() != "") { //do stuff }

The statement is True because of the watermark. Is there anyway I can somehow "ignore" this watermark value for my If statement ?

Thanks

+1  A: 

You could ignore the watermark text as well other than empty:

if (jQuery('#selector').val() != "" && jQuery('#selector').val() != "your watermark text")
{
  //do stuff
}
Sarfraz
hmm yeah thanks sarfraz - this is exactly what I'd thought of myself. Just wondering whether there was something I was completely missing here :) +1 for this
Tom
@Tom: No problem :)
Sarfraz
+3  A: 
if (jQuery('#selector').val() != "" && jQuery('#selector').val() != "'Watermark text here ...'") { //do stuff }

This only assumes that the watermark text is static across examples. If not then you may need a collection of watermark texts?

dredful