Minimal jQuery plugin to add a placeholder text to text fields
JavaScript
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
README.textile
jquery.placeholder.js
jquery.placeholder.min.js
test.html

README.textile

jQuery Placeholder

DESCRIPTION

A very basic, very small placeholder jQuery plugin. It’s only 756 bytes when minified and you can always remove the license text, making it about 300 bytes shorter, but you really shouldn’t do that :)

This plugin is useful when you want a text field to display a value that hints at what the user is supposed to type. Text disapears when text field is focused and restored if the text field is left blank.

Tested with jquery 1.3.2 and 1.4.0.

USAGE

	$("input").placeholder();

OPTIONS

Option Description Default Value
text text to serve as placeholder ‘enter text’
cls class given to element while placeholder text is active ‘placeholder’
clearOnSubmit clear the input if the placeholder text is still active when the parent form is submited true

CHANGELOG

v1.1 Jan 19, 2010

Added clearOnSubmit option.
756 bytes minified

v1.0 Dec 12, 2009

First version of the plugin.
622 bytes minified