I have some <input>
s on my form, and I would like to watermark them with field labels. There are already myriad watermarking plugins, but best as I can tell they all clear the watermark when the <input>
is focused, even if there's nothing entered.
What I'd like, ideally, is something that would continue to display until the user typed something in, focused or not.
Does anyone know of a plugin that does this already, or know of a code sample that might help guide my way?
A simple jQuery example to show you how to implement a watermark text effect on an input field. 1. Code Snippets An email input field and css watermark class. jQuery to apply the watermark effect on email field. 2. Demo Complete HTML source code. Result. Founder of Mkyong.com, love Java and open source stuff.
The focus() is an inbuilt method in jQuery which is used to focus on an element. The element get focused by the mouse click or by the tab-navigating button. Syntax: $(selector).focus(function) Here selector is the selected element. Parameter: It accepts an optional parameter “function” which specifies the function to run when the focus ...
When the user exits the input box if they haven’t added any text, put the watermark back. To do the above, we handle the blur and focus events of the input element.
The Watermark jQuery plugin has an optional property WaterMarkTextColor which can be used to set the color of the Watermark text. * All browser logos displayed above are property of their respective owners.
This plugin will retain the watermark when the input is focused, although it will hide on any keypress (even Ctrl).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With