If you used this.defualtValue instead of the static value "E-Mail" I would have woted up this script but since it's static javascript I'm voting it down. (See my code below for a better way than yours).
----------------------- http://jiart.org/ My digital playground with it's own sandbox. Well anyway, I love programming
-----------------------
http://jiart.org/
My digital playground with it's own sandbox.
Well anyway, I love programming
<input type="text" name="email" value="E-Mail" onfocus="if(this.value==this.defaultValue){this.value=''};" onblur="if(this.value==''){this.value=this.defaultValue};" />
// JavaScript code
function initPage() {
if (document.getElementById) {
var oInput = document.getElementById("my_input");
oInput.onfocus = function() {
if (this.value == this.defaultValue) {
this.value = "";
}
}
oInput.onblur = function() {
if (this.value == "") {
this.value = this.defaultValue;
}
}
}
}
if (window.addEventListener) {
window.addEventListener("load", initPage, false);
} else {
window.attachEvent("onload", initPage);
}
<!-- HTML code -->
<input id="my_input" name="my_input" type="text" value="E-mail">