Posted By

iqwebdev on 07/14/10



Versions (?)

Who likes this?

1 person have marked this snippet as a favorite


Clear Field on Focus

 / 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.

  1. <input type="text" onfocus="if(this.value == 'value') { this.value = ''; }" value="value" />

Report this snippet  

You need to login to post a comment.