Hi,
I've wrote some code that will allow me to have some greyed out text on an input form, and when the user focuses on it, the text will disappear and become ungreyed out, if that makes sense...
function editableAlt (elem, colour1, colour2) {
var elem = document.getElementById(elem);
elem.onfocus = function () {
if(this.value == this.defaultValue) {
this.value = ""; // remove the default text, so the user can enter their own
this.style.color = "#" + colour1; // change the text colour
}
};
elem.onblur = function () {
if(this.value == '') {
this.value = this.defaultValue; // user left it blank? revert back to the default text
this.style.color = "#" + colour2; // and change the colour back too
}
}
}
This is working on most pages, but on one for some reason the onfocus and onblur aren't working at all - for example if I change it to onclick it triggers no problem.
Is there anything else I can try? :( I am using JQuery, but removing that doesn't seem to effect it at all.
Cheers