Unnamed
Posted by dcramer
highlighted in
JavaScript
- ActionScript
- ActionScript 3
- Bash
- Brainfuck
- C
- C#
- C++
- CSS
- Diff
- Django/Jinja
- ERB
- Erlang
- Genshi
- Genshi Text
- Gettext Catalog
- HTML
- INI
- Java
- JavaScript
- Lua
- Mako
- Myghty
- MySQL
- Objective-C
- Perl
- PHP
- Plaintext
- Python
- Python 3
- Python console session
- Python Traceback
- RHTML
- Ruby
- Ruby irb session
- Smarty
- SQL
- VB.net
- XML
- XSLT
var PassiveInputLabel = new Class({
initialize: function(element, label) {
this.element = $(element);
this.label = label;
this.element.addEvents({
'blur': this.test.bind(this),
'focus': function(e){
if (this.element.get('value') == this.label)
{
this.element.set('value', '');
this.element.removeClass('inactive');
}
}.bind(this),
});
this.test();
},
test: function(){
if (!this.element.get('value') || this.element.get('value') == this.label) {
this.element.set('value', this.label);
this.element.addClass('inactive');
}
else {
this.element.removeClass('inactive');
}
}
});