When designing a Form Template, it is sometimes necessary to prevent the value in a particular field from being changed or even seen. In such cases, you can designate a field as read-only or hidden, respectively.

Read-Only

All Form Templates exported from Content Server invoke JavaScript, so you can include JavaScript functions in your HTML customizations. To make a Form read-only, you make use of three JavaScript functions:

In JavaScript, Focus refers to the object (in this case, the field) where the cursor is blinking. Therefore, you can trigger an onFocus() event whenever the cursor enters a particular field. Used in conjunction with this.blur(), an onFocus event causes the cursor to immediately jump to the next field as soon as it enters the field you want to protect. This effectively renders the field read-only:

<INPUT TYPE="text" NAME="_1_1_2_1" ID="_1_1_2_1" VALUE="[LL_FormTag_1_1_2_1
/]" SIZE="32" MAXLENGTH="32" ONFOCUS="this.blur();" ONCHANGE="markDirty();">

The onChange() function tells Content Server that the data in the field has been changed, even though it has not. This is necessary for the Form Template to function properly when it is returned to the Content Server database as a view.

Hidden

You can hide some Form fields and other elements by changing its TYPE attribute to hidden:

<INPUT TYPE="hidden" NAME="_1_1_2_1" ID="_1_1_2_1" VALUE="[LL_FormTag_1_1_2_1
/]" SIZE="32" MAXLENGTH="32" ONFOCUS="" ONCHANGE="markDirty();">

For more information, see Edit an Exported HTML Form Example.