Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

jQuery <input> watermark that stays when focused

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?

like image 942
Tim Sullivan Avatar asked Jan 11 '10 19:01

Tim Sullivan


People also ask

How to implement a watermark text effect on an input field?

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.

How to focus on an element using jQuery?

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 the watermark is put back?

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.

How to change the color of the watermark text in jQuery?

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.


1 Answers

This plugin will retain the watermark when the input is focused, although it will hide on any keypress (even Ctrl).

like image 53
SLaks Avatar answered Sep 27 '22 22:09

SLaks