9.13. Hidden Fields

You can place additional, nonvisible data in your forms using hidden fields. The hidden field has the following format:

<input type="hidden" name="name_of_field" value="value_of_field" />

Other than not being visibly displayed, hidden fields are much like any other field. Hidden fields are used mostly for tracking data and the state of a process. For example, in a multipage form, a userid field can be hidden in the form to ensure that subsequent forms, when submitted, are tied to the same user data. For instance, the following code could be used to track a user by a unique number:

<input type="hidden" name="userid" value="4384572332" />

Keep in mind that while hidden fields do not display in the user agent interface, they are still visible in the code of the document. Hidden fields should never be used for sensitive data.

Get Web Standards Programmer's Reference: HTML, CSS, JavaScript®, Perl, Python®, and PHP 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.