The modest Javascript placeholder
SeatHolder is a small Javascript library which lets you display placeholder text (so called seatholders
) and place default values to text inputs and textareas with great ease. It uses jQuery (http://jquery.com) to keep your HTML as clean as possible.
Just include SeatHolder after you have included jQuery:
<script src="path/to/jquery.js" type="text/javascript"></script> <script src="path/to/seat_holder.js" type="text/javascript"></script>
Note: include seat_holder-min.js
for the minified SeatHolder library
Make sure you put the jquery
directory in the same directory as the SeatHolder library:
| |-- seat_holder.js | |-- jquery | |-- core.js
Just include SeatHolder:
<script src="path/to/seat_holder.js" type="text/javascript"></script>
Note: include seat_holder-min.js
for the minified SeatHolder library
Just add the seatholder
attribute to your inputs:
<form> ... <input type="text" name="user[first_name]" seatholder="Your first name"> <textarea name="question[body]" seatholder="Please specify your question"></textarea> ... </form>
As stated above, you can also specify default values for text inputs and textareas. Just start the seatholder
attribute with '&'
:
<form> ... <input type="text" name="object[title]" seatholder="&SeatHolder Demo"> <textarea name="object[body]" seatholder="&I would like to receive more information"></textarea> ... </form>
For a complete live demo, please visit http://codehero.es/demos/seat_holder and http://gettopup.com/demo.
You can tell SeatHolder whether to react on focus events of hinted elements are not and it does at default of course. Just call SeatHolder.react(bool)
in which bool
can be left undefined (it will be assumed as true
) or can be a boolean (SeatHolder will not react on focus events when false
).
For support, remarks and requests please mail me at paul.engel@holder.nl.
This Javascript library depends on:
jQuery
http://jquery.com
None
Copyright © 2010 Paul Engel, released under the MIT license
http://holder.nl – http://codehero.es – http://gettopup.com – http://twitter.com/archan937 – paul.engel@holder.nl
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.