Tutorial 13: Giving Form to Forms - HTML with Style | 11 | WebReference

Tutorial 13: Giving Form to Forms - HTML with Style | 11

index123456789101112131415161718192021exercises1

Tutorial 13: Giving Form to Forms

Disabled controls

Disabled control attribute

DISABLED (Boolean)
When present, this attribute indicates that the form control is disabled.

All controls have a DISABLED attribute that can be used to make a control disabled. A disabled control cannot be manipulated by the user. However, you can use client-side scripts to modify this control and enable it at some point. This can be useful, for instance, to enable a submit button only after the user has entered all required data. Note, however, that since a user may not have access to your script, it is a good idea to disable controls through the script itself rather than using the attribute in HTML. This way, the control will only be disabled if it can be re-enabled (because you know that the script is running). Disabled control's names and values are never submitted with the form.

<FORM ACTION="/cgi-bin/html/formdump.cgi" 
      METHOD="GET" ENCTYPE="application/x-www-form-urlencoded">
<P>Do you want to receive periodic 
e-mails about our products?
<INPUT TYPE="checkbox" NAME="spam" VALUE="yes" CHECKED DISABLED>
<P><INPUT TYPE="Submit">
</FORM>

Do you want to receive periodic e-mails about our products?

Read-only controls

Read-only control attribute

READONLY (Boolean)
When present, this attribute indicates that the form control is read-only.

Read-only controls are similar to disabled controls in that they cannot be modified by the user, but the difference is that their names and values are used when the form is submitted. You can find a number of uses for read-only controls, but again most involve scripting. Not all controls can be made read-only, but those that can't (such as submit buttons) wouldn't make much sense anyway - if you can't activate a submit button, its data is not going to be used for the form anyway.

<FORM ACTION="/cgi-bin/html/formdump.cgi" METHOD="GET" 
      ENCTYPE="application/x-www-form-urlencoded">
<P>Please enter any comments you feel are relevant below.
<P><TEXTAREA NAME="comments" ROWS="5" COLS="50" READONLY>
I just love your products!</TEXTAREA>
<INPUT TYPE="submit">
</FORM>

Please enter any comments you feel are relevant below.

index123456789101112131415161718192021exercises1

Produced by Stephanos Piperoglou

URL: https://www.webreference.com/html/tutorial13/18.html

Created: May 28, 1998
Revised: February 25, 1999