Is it possible for a disabled <input>
tag to support text selection?
Asked
Active
Viewed 1.7k times
28

Nick Heiner
- 119,074
- 188
- 476
- 699
5 Answers
44
You could use the ReadOnly attribute.

g.d.d.c
- 46,865
- 9
- 101
- 111
-
3Probably the only fix. Note that this is not identical to the `disabled` attribute - the value in the field will be submitted to the receiving script – Pekka Jan 18 '11 at 16:58
-
Also notice that readonly field can be modified by a script for example. Think about autocomplete scripts for example: as the field gets focus, the script can show other values that can be chosen. So be careful. – alci May 31 '13 at 14:49
-
1It's not working, you can still select text in the input with `readonly` attribute – KimchiMan Dec 03 '17 at 00:53
-
2@KimchiMan - This question was asked and answered more than 6 years ago. Yes, you can still select the text. That's the _point_. That was _what the OP asked for_. – g.d.d.c Dec 03 '17 at 01:55
-
@g.d.d.c Oh sorry - my bad – KimchiMan Dec 17 '17 at 01:42
20
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.)

Pops
- 30,199
- 37
- 136
- 151
2
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"...

bensiu
- 24,660
- 56
- 77
- 117
-
This is wrong, readonly sends the field with the form, disabled doesn't. – Odalrick Nov 04 '20 at 13:11