This paper introduces several methods of JS to realize read-only:
To set the control to read-only, we need to know what does not readolny this property
I know that the checkbox and RadioButton do not have readolny this attribute, and I have already described how to set the checkbox to read-only in the previous article.
Today we just understand that universal controls are read-only and unavailable
document.getElementById (Textid). Disabled=true;
document.getElementById (textid). SetAttribute ("Disabled", true);
document.getElementById (Textid). Readonly=true;
document.getElementById (textid). SetAttribute ("readOnly", true);
The value of the first input becomes gray, and the color of the second input is displayed correctly.
Style modification
document.getElementById (Textid). Classname= "";
Supplemental Note: When the control is set to Disabled=true, JS is not getting the value of this control.
JS control to set read-only and unavailable properties