Skip to content


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 Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.