function initInputs() { var _inputs = document.getElementsByTagName('input'); if (_inputs) { for(var i=0; i<_inputs.length; i++) { if (_inputs[i].type == 'text' || _inputs[i].type == 'password') { _inputs[i].alt = _inputs[i].value; _inputs[i].onfocus = function(){ if(this.value==this.alt) this.value=''; _value = this.value; } _inputs[i].onblur = function(){ if (this.value == '') this.value = this.alt; } } } } } if (window.addEventListener) window.addEventListener("load", initInputs, false); else if (window.attachEvent) window.attachEvent("onload", initInputs);