How To Create An Input Field Watermark Using jQuery

Here is a VERY simplistic watermark code snippet. It has the distinct disadvantage of submitting the watermark string as the field value, and does not set the initial field value either…YMMV…
1 2 3 4 5 6 7 |
jQuery('#yourInput') .focusin(function() { if (jQuery('#yourInput').val() == 'Enter keywords to search for') jQuery('#yourInput').val(''); }) .focusout(function() { if (jQuery('#yourInput').val() == '') jQuery('#yourInput').val('Enter keywords to search for'); }); |
Leave Your Comment
All fields marked with "*" are required.