Skip to content

Instantly share code, notes, and snippets.

@joshualambert
Created January 2, 2014 16:44

Revisions

  1. joshualambert created this gist Jan 2, 2014.
    23 changes: 23 additions & 0 deletions hintTextShim
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,23 @@
    // Used to fake hintText coloring to the font color.
    // Requires hintText to be defined on the object being passed.
    function hintTextShim(uiObject, isPswd) {
    uiObject.objectFocus = function () {
    if (uiObject.value === uiObject.hintText) {
    if (typeof isPswd !== 'undefined' && isPswd === true) {
    uiObject.passwordMask = true;
    }
    uiObject.value = '';
    }
    };
    uiObject.objectBlur = function () {
    if (uiObject.value === '') {
    if (typeof isPswd !== 'undefined' && isPswd === true) {
    uiObject.passwordMask = false;
    }
    uiObject.value = uiObject.hintText;
    }
    };
    uiObject.addEventListener('focus', uiObject.objectFocus);
    uiObject.addEventListener('blur', uiObject.objectBlur);
    uiObject.objectBlur(); // Go ahead and set the default hintText.
    }