Simply add the following to the the onFocus
attribute of any HTML form input tag.
if (this.value == this.defaultValue) this.value = '';
this.defaultValue is automatically given the value in the HTML.
Simply add the following to the the onFocus
attribute of any HTML form input tag.
if (this.value == this.defaultValue) this.value = '';
this.defaultValue is automatically given the value in the HTML.
Comments
2 responses to “JS: Clear Default Value onFocus”
Here is an extention to the clear default value onFocus:
onBlur=”if (this.value == ”) this.value = this.defaultValue;”
It reenters the default value if it is left empty onBlur.
Thanks Eddie.