Javascript Form How to - Clear text field on focus








Question

We would like to know how to clear text field on focus.

Answer


<html>
<body>
    <form action="">
      <input type="text" name="emailAD" size="15" value="Email Address" onfocus="this.value=''">
      <br /><submit value="Subscribe">
    </form>
</body>
</html>

The code above is rendered as follows: