Call Us Today! (866) 377-4331 or Request a Quote

Highlight text box contents on click

A project I was working on today for web design client in Los Angeles that involved a whole heck of a lot of form fields to run the custom administration panel. I needed a quick and easy way to allow the client to change or delete everything in each field as quickly as possible. The best method is to highlight everything in the field using the onFocus() and select() JavaScript functions. It’s one of the easiest JavaScript tricks you can use.

<input type="text" id="textfield" onfocus="javascript: this.select();" />

Now isn’t that nice and simple? And the added usability is so great your clients will love you. You don’t have to tell them how little work it actually took. :-P

Comments are closed.