Skip to content

Instantly share code, notes, and snippets.

@SeanTAllen
Created January 22, 2011 17:52
Show Gist options
  • Save SeanTAllen/791300 to your computer and use it in GitHub Desktop.
Save SeanTAllen/791300 to your computer and use it in GitHub Desktop.
from schwab.com wherein they delete the password field and recreate it... why the first one is considered a 'dummy'... eh? messes with password savers, autofill etc.
// replace password dummy with real field on focus:
function pwFocus(id) {
var elm = document.getElementById(id);
if (elm.value == "Password") {
var newElm = document.createElement("input");
var elmWrapper = document.getElementById("pwBox");
newElm.setAttribute("type", "password");
newElm.setAttribute("name", id);
newElm.setAttribute("id", id);
newElm.setAttribute("onblur", "pwBlur(this.id);");
elmWrapper.replaceChild(newElm, elm);
setTimeout( function() { document.getElementById(id).focus()}, 1);
}
}
function pwBlur(id) {
var elm = document.getElementById(id);
if (elm.value == "Password" || elm.value.length == 0) {
var elm = document.getElementById(id);
var newElm = document.createElement("input");
var elmWrapper = document.getElementById("pwBox");
newElm.setAttribute("type", "test");
newElm.setAttribute("name", id);
newElm.setAttribute("id", id);
newElm.setAttribute("value", "Password");
newElm.setAttribute("style", "color: #999");
newElm.setAttribute("onfocus", "pwFocus(this.id);");
elmWrapper.replaceChild(newElm, elm);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment