TextLabelInput 0.2
This plugin allows a text input field to use its initial value as the label. The value is displayed as normal, but when the user focuses on the text field, the value is emptied to allow the user to complete their input.
Details
- Author
- Greggory Hernandez
- Current version
- 0.2
- GitHub
- greggoryhz/TextLabelInput
- Downloads
- 3016
- Category
- Widgets
- Tags
- Report
- GitHub Issues
How to use
Assuming:
<input type="text" value="initial label" id="text_field" />
Then this will initialize the TextLabelInput:
new TextLabelInput('text_field');
You can also pass options as the second parameter (defaults are shown):
new TextLabelInput('text_field', {
label: $('text_field').value,
active_color: 'black',
inactive_color: '#8a8a8a',
beforeRemove: function () {},
afterRemove: function () {},
beforeReplace: function () {},
afterReplace: function () {}
});
Options
- label - A string. This is used to set the label to something besides the elements value
- active_color - A string. This is an HTML color code to set the color of the text when the text field has focus
- inactive_color - A string. This is an HTML color code to set the color of the text when the text field does not have focus
- beforeRemove - A function. This is called right before the label is removed (on focus if no text has been entered)
- afterRemove - A function. This is called right after the label is removed
- beforeReplace - A function. This is called right before the label is replaced (on blur if no text has been entered)
- afterReplace - A function. This is called right after the label is replaced
Examples: http://grehz.com/textlabelinput/example.html
Discuss
A note on comments here: These comments are moderated. No comments will show up until they are approved. Comments that are not productive (i.e. inflammatory, rude, etc) will not be approved.
Found a bug in this plugin? Please report it this repository's Github Issues.
blog comments powered by Disqus