on focus

Clear form fields on focus

If you want to make a form without labels for text inputs or textareas, and instead give the fields default values, you will encounter a little annoying  problem, when you focus the field to write something the default value stays there. To make the default value disappear you will need a few lines of javascript.

$('textarea, input:text').bind('focus click', function(){
		if (this.value == this.defaultValue) {
		this.value = '';
	}).bind('blur', function(){
		if (this.value == '') {
		this.value = this.defaultValue;

Note that this script uses jQuery so in order to work you’ll need to have jQuery installed.

To make all clear here is a demo.