Skip to content

Instantly share code, notes, and snippets.

@earlonrails
Created November 26, 2011 23:25
Show Gist options
  • Save earlonrails/1396494 to your computer and use it in GitHub Desktop.
Save earlonrails/1396494 to your computer and use it in GitHub Desktop.
Clear Field on Focus and restore if nothing entered javascript and html input.
function autoUnput(thefield, orig){
if(orig){
if(thefield.value == ''){
thefield.value = orig;
}
} else if (thefield.defaultValue==thefield.value){
thefield.value = "";
}
}
<input type="text" onfocus="autoUnput(this)" onblur="autoUnput(this, 'Email')" value="Email" />
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment