JQuery watermark and using .Val ()

My problem is that I am using a simple watermark plugin so that it works

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

The problem is when I try to use something like

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

TrueWatermark application . Anyway, can I somehow “ignore” this watermark value for my operator If?

thank

+3
source share
3 answers
if (jQuery('#selector').val() != "" && jQuery('#selector').val() != "'Watermark text here ...'") { //do stuff }

This implies that the watermark text is static by example. If not, then you may need a collection of watermarked texts?

+3
source

You can ignore the watermark text rather than blank:

if (jQuery('#selector').val() != "" && jQuery('#selector').val() != "your watermark text")
{
  //do stuff
}
+1
source

:

Jquery: val() 'undefined' ?

The essence of the solution in your case:

if ((jQuery('#selector').not('.watermark').val()||'') != "") { //do stuff }
0
source

Source: https://habr.com/ru/post/1765873/


All Articles