Keeping Elements from Being Changed

Sometimes it may be necessary to automatically set the contents of a form element and keep the visitor from changing it. For example, you could have the visitor confirm information, or you could show a past history of transactions and then submit that information again with the new data collected. You can do this by making the element “read-only”.

To keep elements from being changed:

Type readonly="readonly" in the form element’s tag.

Figure 17.61. Add the readonly attribute to any form element that you want to show to your visitors but that you don’t want them to change.

Figure 17.62. In this example, ...

Get HTML, XHTML, & CSS, Sixth Edition: Visual QuickStart Guide now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.