Nick Heiner
Nick Heiner

Reputation: 122392

Disabled <input> that allows text selection?

Is it possible for a disabled <input> tag to support text selection?

Upvotes: 29

Views: 18110

Answers (5)

g.d.d.c
g.d.d.c

Reputation: 47968

You could use the ReadOnly attribute.

Upvotes: 45

Pops
Pops

Reputation: 30818

Based on the HTML spec, it looks like no:

  • Disabled controls do not receive focus.
  • Disabled controls are skipped in tabbing navigation.
  • Disabled controls cannot be successful.

Are you able to use the readonly attribute instead?

(Wow, "4 new answers have been posted"... I think the spec link is helpful, at least.)

Upvotes: 20

bensiu
bensiu

Reputation: 25554

readonly="readonly" is your answer

you can remove border in CSS or directly in styles, when you "blocked" this field and it will look like regular text, bring back the look when "unblocked"...

Upvotes: 2

&#193;lvaro Gonz&#225;lez
&#193;lvaro Gonz&#225;lez

Reputation: 146330

You may want to use a readonly input and style it with CSS.

Upvotes: 3

Pekka
Pekka

Reputation: 449385

This will depend heavily on the browser. It works fine for me in Chrome and IE8: JSFiddle

Firefox (3.6) seems to be the one browser that doesn't support it. I don't think you can do anything about that.

Upvotes: 3

Related Questions