Thomas Fuchs has created defaultValueActsAsHint, an implementation of the Input Prompt pattern. I like the idea to have this function, but I use dojo and so I implement it for dojo: function defaultValueActAsHint(elem) { var element = elem; element.defaultValue = element.value; dojo.attr(element, “class”, “hint”); dojo.connect(elem, “onfocus”, null, function() { if(element.defaultValue != element.value) return; dojo.attr(element, “class”, “”); element.value = ”; }); dojo.connect(elem, “onblur”, null, function() { if(element.value != ”) return; dojo.attr(element, “class”, “hint”); element.value = element.defaultValue; }); }
Leave a Comment
Published 09.01.09