JavaScript is great for usability - there are a million different little tricks you can use to make your site more user-friendly, especially when it comes to forms. In this quick tutorial I show you how to setup a form text field contents to be highlighted when clicked on. This allows for quick editing in case you need to replace the contents of the field.
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.
