WEB front end: input setting is disabled, non editable, non selectable, and value can/cannot be transferred

The same project needs to preset the input value first, but does not want to be modified or edited, so this function is required. Usually use "disable..."

The same project

You need to preset the input value first, but do not want to be modified or edited, so you need this function.


Usually "disabled" is used, but there is a problem that the background cannot receive the transmitted value

 <input type="text" disabled="disabled" />

The disabled input element cannot be edited, copied, selected, received the focus, and the background will not receive the value. The color of the text will turn gray after setting.


Secondly, we can use readonly unselectable='on '

 <input type="text"  readonly  unselectable="on" >

This situation is similar to using disable. The input element cannot be edited, copied, selected, or receive the focus. After setting, the text color will also become gray, but the background can receive the value

In most cases, this is OK


In addition, there is another form

 <input type="text" readonly="readonly">

Finally, in this case, the input element is read-only and can be copied. You can use the Tab key to switch to this field. You can select, receive the focus, or select or copy its text. The background will receive the value. This property prevents users from modifying values.


During its development, it can be selected according to actual needs

comment