Highlight or Delete Form Field Data on Click with Javascript

Sometimes you want to highlight or delete the value of an HTML form field when a user clicks on it. This is very simple to do using javascript. Just add the following to your input tag:

To Highlight:
onFocus=”this.select()”

To Delete:
onFocus=”this.value=””

Here are examples of how each of these works:

Have fun and be careful!