W3C home > Mailing lists > Public > w3c-wai-ig@w3.org > April to June 2002

Re: place-holding characters in form elements

From: Tom Gilder <w3c@tom.me.uk>
Date: Thu, 23 May 2002 21:40:58 +0100
Message-ID: <19580733547.20020523214058@tom.me.uk>
To: w3c-wai-ig@w3.org
On Thursday, May 23, 2002, 12:01:54 PM, Nick Kew wrote:
> <input name="date" value="YYYY-MM-DD" onfocus="value=''">
> shouldn't be too confusing, but can never be more than an ad-hoc usage.

However, is a user enters data and then accidently tabs or clicks away and then
focuses back on the field, the data will be cleared.

If you really feel the need for default text, then it is better to do something
along the lines of:

  <input name="date" value="YYYY-MM-DD"
  onfocus="if(!this.cleared){this.value='';this.cleared=true;}" />

This should only clear the text once.
  
You can also do this.select() onfocus, to select all the text - when the user
starts typing, that text will generally be deleted. Often users don't realize
this however, and delete the text first anyway.

-- 
Tom Gilder
http://tom.me.uk/
Received on Thursday, 23 May 2002 16:41:03 GMT

This archive was generated by hypermail 2.2.0+W3C-0.50 : Tuesday, 19 July 2011 18:14:04 GMT