To disable an input type=text with JavaScript, we set the disabled or readOnly property.
For instance, we write
document.getElementById("foo").disabled = true;
or
document.getElementById("foo").readOnly = true;
to get the input with getElementById.
Then we disable the input by setting the disabled or readOnly property to true.
readOnly keeps the original input style when disabled.
disabled grays out the input when disabled.