On editing form text fields Sep08 '05

On many web forms, it’s typically desirable to do one of two things:

  1. Provide brand new information
  2. Edit previously entered information

If the user is entering brand new information, sometimes there is already an example value in the text field. This is helpful in assisting the user as to what type of data should be entered. If this is the case - when the user enters that field, all of the text should be selected, so the user doesn’t have to delete text, before they enter their own:

Example of how the highlighted text appears

If the user is editing previously entered information, then they probably won’t want all of the text to be selected.

Why is this the case?

Because sometimes it’s desirable to edit only a portion of the text string, such as a word in the middle. If all of the text is selected, then the user has to click more than once, just to get the curser to the right spot.

For example, the first click would highlight all of the text, and the second click would provide the curser at the exact spot clicked. Two clicks is too much, just to start typing in a text field.

Below are two examples, to try out. The first text field highlights all of the text, when you click in the field. The second one positions the curser wherever you click.

Brand New
Previously Entered

In the "Previously Entered" example - suppose you just wanted to change the word ‘entered’ to something else. You can easily just click near the word ‘entered,’ and use the keyboard to edit it.

JavaScript use

The first example, "Brand New," uses a small snippet of JavaScript, within the input element:

onFocus="this.select()"

Categories: JavaScript , Usability , Web Development

Add Feedback (view all)

Leave feedback

Feedback

Input format: The editor controls below will assist with Markdown syntax.

Status

Sub-status

Your info

matthom is published and produced by Matt Thommes - an independent publishing enthusiast, mobile blogger, content creator, informative writer, web developer from Chicago. Never one to conform, Matt intends to promote the effect the web has on our lives, in an effort to intensify, instruct, and clarify all that is happening around us.

Contact Matt

Similar Entries

Stats

114 unique visits since August 2008

Syndicate

Advertisements