It has come very handy and re-usable in other sites.
Just add the class 'default_value' to your Textbox or input controls <input class="'default_value' /> and that's it. When you click on the textbox the default text will disappear. If you don't enter any value on blur the default value will be displayed in the input again.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Event.observe(window, 'load', function() { | |
$$('input.default_value', 'textarea.default_value') | |
.invoke('observe', 'focus', function(e) { | |
if (this.hasClassName('default_value')) { | |
this.value=''; | |
this.removeClassName('default_value'); | |
} | |
}) | |
.invoke('observe', 'blur', function(e) { | |
if (this.value=='') { | |
this.addClassName('default_value'); | |
this.value=this.defaultValue; | |
} | |
}) | |
}); |
No comments:
Post a Comment