Mirage Design Works » Blog Archive » Highlight Contents of a Text Box On Click

Highlight Contents of a Text Box On Click

March 12th, 2008 by John Crenshaw

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 admin backend of the website. 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…

<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 ;)

2 Responses to “Highlight Contents of a Text Box On Click”

  1. kannak Says:

    plz give sugession..
    i want to select a particular text in a textbox while on click the text

  2. John Crenshaw Says:

    That’s what this does. Did you try it?

Leave a Reply