problem with Chrome form handling: input onfocus="this.select()"
Posted
by binaryorganic
on Stack Overflow
See other posts from Stack Overflow
or by binaryorganic
Published on 2010-05-30T14:59:33Z
Indexed on
2010/05/30
15:02 UTC
Read the original article
Hit count: 409
I'm using the following HTML code to autoselect some text in a form field when a user clicks on the field:
input onfocus="this.select()" type="text" value="Search"
This works fine in Firefox and Internet Explorer (the purpose being to use the default text to describe the field to the user, but highlight it so that on click they can just start typing), but I'm having trouble getting it to work in Chrome. When I click the form field in Chrome the text is highlighted for just a split second and then the cursor jumps to the end of the default text and the highlighting goes away.
Any ideas on how to get this working in Chrome as well?
© Stack Overflow or respective owner