Last Updated: February 25, 2016
·
511
· raf_vs

Clear form fields on focus

Simple little snippet I've used a lot.

$("input:not('.exclude'), textarea").focus(function() {
    if( this.value == this.defaultValue ) {
        this.value = "";
    }
    }).blur(function() {
    if( !this.value.length ) {
        this.value = this.defaultValue;
    }
});