Skip to content

Instantly share code, notes, and snippets.

@salieridk
Created April 17, 2012 10:42
Show Gist options
  • Save salieridk/2405210 to your computer and use it in GitHub Desktop.
Save salieridk/2405210 to your computer and use it in GitHub Desktop.
Javascript: cleartext function
function clearText(field){
if (field.defaultValue == field.value) {field.value = '';}
else if (field.value == '') field.value = field.defaultValue;
}
<input type="text" size="25" id="test" name="test" value="indtasningsfelt" onFocus="clearText(this)" onBlur="clearText(this)">
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment