/ Published in: JavaScript
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.
Alternatively, use onfocus=â€this.value=â€;†to always clear the field.
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
<input type="text" onfocus="if(this.value == 'value') { this.value = ''; }" value="value" />