Question: Is there a way to disable an input field, i.e. allow text to be displayed, but not changed ?
The first technique makes it difficult to put keyboard focus in the edit box. If you can't get your cursor there, you certainly can't edit it.
<script> disabled = true; </script> <form> <input type=text value="try to edit me" onFocus="if (disabled) blur ();"> </form>
The second technique is not as nice, but it is more reliable. It allows the box to be edited, but quickly returns it to its original state as soon as focus leaves the box.
<script> disabled = true; </script> <form> <input type=text value="try to edit me" onChange="if (disabled) form . reset ();"> </form>
One nice feature about Kludge #2 is that it allows the user to select the text and copy it to the clipboard. This is not possible with Kludge #1.
Perhaps the best solution is a combination of the two.
30 August 1997