function find_default_inputs() { inputs = document.getElementsByTagName('input'); for( i=0; i<=inputs.length; i++){ if( inputs[i] && inputs[i].className && inputs[i].className.match('default') ) { inputs[i].onfocus = default_input_focus inputs[i].onblur = default_input_blur inputs[i].value = inputs[i].id try { inputs[i].type = 'text' } catch(e){} } } } function default_input_blur() { if ( this.value == "" ) { this.value = this.id; if ( this.className.match( 'password' ) ) { try { this.type = 'text'; } catch(e){} } } } function default_input_focus() { if ( this.value == this.id ) { this.value = ""; if ( this.className.match( 'password' ) ) { try { this.type = 'password'; } catch(e){} } } } window.onload = find_default_inputs;