Code Snippets Gallery
Clear Field on Focus
<input type="text" onfocus="if(this.value == 'value') { this.value = ''; }" value="value" />Replace “value” with the default value. If the field is selected, the default value will go away. If the user has previously changed the field value, it’ll be left alone.
Alternatively, use onfocus=”this.value=”;” to always clear the field.
What about having ONBLUR as well? Just in case the user doesn’t enter anything and leaves the field.
Sorry, my code did not show up. Let me try again…
What if the field is connected to a table and the iput field is pre defined?
Example: I have a field “S” that comes up null in a web page, the user makes a mistake and instead of going back and highlighting and deleting they could just click the reset button. If I use input type=”text” it just creates another blank field. I want it to reference the predefined field.