jquery - How to remove input watermark if the field is not empty? -



jquery - How to remove input watermark if the field is not empty? -

i have code add together watermark on input. input page title. works ok. write caption, watermark disappears (that's right). if i'm editing content, title disappears , watermark again. why watermark returns when input field contains content?

<script type="text/javascript"> $(document).ready(function() { var watermark = 'write city + state (separated commas)'; //init, set watermark text , class $('#edit-title').val(watermark).addclass('watermark'); //if blur , no value inside, set watermark text , class again. $('#edit-title').blur(function(){ if ($(this).val().length == 0){ $(this).val(watermark).addclass('watermark'); } }); //if focus , text watermrk, set empty , remove watermark class $('#edit-title').focus(function(){ if ($(this).val() == watermark){ $(this).val('').removeclass('watermark'); } }); }); </script>

sorry english. tips.

the functionality looking phone call placeholder. add together in html5 , major web browser back upwards it.

here have definitions , usage.

you don't need utilize js in order archive this.

greetings

jquery drupal input watermark

Comments

Popular posts from this blog

xslt - DocBook 5 to PDF transform failing with error: "fo:flow" is missing child elements. Required content model: marker* -

mediawiki - How do I insert tables inside infoboxes on Wikia pages? -

Local Service User Logged into Windows -