How to mark (highlight) a text-field onFocus

  • Thread starter Per Magnus L?vold
  • Start date
P

Per Magnus L?vold

Hi!
I'm working on a JSP application, and wish to define a text-field so
that it becomes marked (highligted) when it obtains focus.

I've tried giving the text-field a value when it obtains focus, but
the value is not marked. So if i wish to alter the value, I have to
manually delete the given 'onFocus' value before I set a new value.

<INPUT TYPE=TEXT NAME=test size=30 onFocus=\"this.value='I want this
to be highlighted!'\">

I'm missing something to highlight the text-field text in the code
above.
Hope someone can help me! :)

Regards,
Per Magnus
 
M

Martin Honnen

Per Magnus L?vold wrote:

I'm working on a JSP application, and wish to define a text-field so
that it becomes marked (highligted) when it obtains focus.

<input type="text"
name="inputName"
value="Kibology"
onfocus="this.select();">

will do, however you might want to implement some logic to call select
only as long as the default value is displayed as it is probably not
helpful to the user that his input is selected.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,770
Messages
2,569,584
Members
45,075
Latest member
MakersCBDBloodSupport

Latest Threads

Top