Annotation of html5/spec/the-form-element.html, revision 1.211
1.202 sruby 1: <!DOCTYPE html><html lang="en-US-x-Hixie"><meta charset="utf-8"><title>4.10.3 The form element — HTML5</title><style type="text/css">
1.198 sruby 2:
3: .applies thead th > * { display: block; }
4: .applies thead code { display: block; }
5: .applies tbody th { white-space: nowrap; }
6: .applies td { text-align: center; }
7: .applies .yes { background: yellow; }
8:
9: .matrix, .matrix td { border: hidden; text-align: right; }
10: .matrix { margin-left: 2em; }
11:
12: .dice-example { border-collapse: collapse; border-style: hidden solid solid hidden; border-width: thin; margin-left: 3em; }
13: .dice-example caption { width: 30em; font-size: smaller; font-style: italic; padding: 0.75em 0; text-align: left; }
14: .dice-example td, .dice-example th { border: solid thin; width: 1.35em; height: 1.05em; text-align: center; padding: 0; }
15:
16: td.eg { border-width: thin; text-align: center; }
17:
18: #table-example-1 { border: solid thin; border-collapse: collapse; margin-left: 3em; }
19: #table-example-1 * { font-family: "Essays1743", serif; line-height: 1.01em; }
20: #table-example-1 caption { padding-bottom: 0.5em; }
21: #table-example-1 thead, #table-example-1 tbody { border: none; }
22: #table-example-1 th, #table-example-1 td { border: solid thin; }
23: #table-example-1 th { font-weight: normal; }
24: #table-example-1 td { border-style: none solid; vertical-align: top; }
25: #table-example-1 th { padding: 0.5em; vertical-align: middle; text-align: center; }
26: #table-example-1 tbody tr:first-child td { padding-top: 0.5em; }
27: #table-example-1 tbody tr:last-child td { padding-bottom: 1.5em; }
28: #table-example-1 tbody td:first-child { padding-left: 2.5em; padding-right: 0; width: 9em; }
29: #table-example-1 tbody td:first-child::after { content: leader(". "); }
30: #table-example-1 tbody td { padding-left: 2em; padding-right: 2em; }
31: #table-example-1 tbody td:first-child + td { width: 10em; }
32: #table-example-1 tbody td:first-child + td ~ td { width: 2.5em; }
33: #table-example-1 tbody td:first-child + td + td + td ~ td { width: 1.25em; }
34:
35: .apple-table-examples { border: none; border-collapse: separate; border-spacing: 1.5em 0em; width: 40em; margin-left: 3em; }
36: .apple-table-examples * { font-family: "Times", serif; }
37: .apple-table-examples td, .apple-table-examples th { border: none; white-space: nowrap; padding-top: 0; padding-bottom: 0; }
38: .apple-table-examples tbody th:first-child { border-left: none; width: 100%; }
39: .apple-table-examples thead th:first-child ~ th { font-size: smaller; font-weight: bolder; border-bottom: solid 2px; text-align: center; }
40: .apple-table-examples tbody th::after, .apple-table-examples tfoot th::after { content: leader(". ") }
41: .apple-table-examples tbody th, .apple-table-examples tfoot th { font: inherit; text-align: left; }
42: .apple-table-examples td { text-align: right; vertical-align: top; }
43: .apple-table-examples.e1 tbody tr:last-child td { border-bottom: solid 1px; }
44: .apple-table-examples.e1 tbody + tbody tr:last-child td { border-bottom: double 3px; }
45: .apple-table-examples.e2 th[scope=row] { padding-left: 1em; }
46: .apple-table-examples sup { line-height: 0; }
47:
48: .details-example img { vertical-align: top; }
49:
50: #base64-table {
51: white-space: nowrap;
52: font-size: 0.6em;
53: column-width: 6em;
54: column-count: 5;
55: column-gap: 1em;
56: -moz-column-width: 6em;
57: -moz-column-count: 5;
58: -moz-column-gap: 1em;
59: -webkit-column-width: 6em;
60: -webkit-column-count: 5;
61: -webkit-column-gap: 1em;
62: }
63: #base64-table thead { display: none; }
64: #base64-table * { border: none; }
65: #base64-table tbody td:first-child:after { content: ':'; }
66: #base64-table tbody td:last-child { text-align: right; }
67:
68: #named-character-references-table {
69: white-space: nowrap;
70: font-size: 0.6em;
71: column-width: 30em;
72: column-gap: 1em;
73: -moz-column-width: 30em;
74: -moz-column-gap: 1em;
75: -webkit-column-width: 30em;
76: -webkit-column-gap: 1em;
77: }
78: #named-character-references-table > table > tbody > tr > td:first-child + td,
79: #named-character-references-table > table > tbody > tr > td:last-child { text-align: center; }
80: #named-character-references-table > table > tbody > tr > td:last-child:hover > span { position: absolute; top: auto; left: auto; margin-left: 0.5em; line-height: 1.2; font-size: 5em; border: outset; padding: 0.25em 0.5em; background: white; width: 1.25em; height: auto; text-align: center; }
81: #named-character-references-table > table > tbody > tr#entity-CounterClockwiseContourIntegral > td:first-child { font-size: 0.5em; }
82:
83: .glyph.control { color: red; }
84:
85: @font-face {
86: font-family: 'Essays1743';
1.204 sruby 87: src: url('fonts/Essays1743.ttf');
1.198 sruby 88: }
89: @font-face {
90: font-family: 'Essays1743';
91: font-weight: bold;
1.204 sruby 92: src: url('fonts/Essays1743-Bold.ttf');
1.198 sruby 93: }
94: @font-face {
95: font-family: 'Essays1743';
96: font-style: italic;
1.204 sruby 97: src: url('fonts/Essays1743-Italic.ttf');
1.198 sruby 98: }
99: @font-face {
100: font-family: 'Essays1743';
101: font-style: italic;
102: font-weight: bold;
1.204 sruby 103: src: url('fonts/Essays1743-BoldItalic.ttf');
1.198 sruby 104: }
105:
1.202 sruby 106: </style><link href="data:text/css," id="complete" rel="stylesheet" title="Complete specification"><link href="data:text/css,.impl%20{%20display:%20none;%20}%0Ahtml%20{%20border:%20solid%20yellow;%20}%20.domintro:before%20{%20display:%20none;%20}" id="author" rel="alternate stylesheet" title="Author documentation only"><link href="data:text/css,.impl%20{%20background:%20%23FFEEEE;%20}%20.domintro:before%20{%20background:%20%23FFEEEE;%20}" id="highlight" rel="alternate stylesheet" title="Highlight implementation requirements"><style type="text/css">
1.1 mike 107: pre { margin-left: 2em; white-space: pre-wrap; }
108: h2 { margin: 3em 0 1em 0; }
109: h3 { margin: 2.5em 0 1em 0; }
110: h4 { margin: 2.5em 0 0.75em 0; }
111: h5, h6 { margin: 2.5em 0 1em; }
112: h1 + h2, h1 + h2 + h2 { margin: 0.75em 0 0.75em; }
113: h2 + h3, h3 + h4, h4 + h5, h5 + h6 { margin-top: 0.5em; }
114: p { margin: 1em 0; }
115: hr:not(.top) { display: block; background: none; border: none; padding: 0; margin: 2em 0; height: auto; }
116: dl, dd { margin-top: 0; margin-bottom: 0; }
117: dt { margin-top: 0.75em; margin-bottom: 0.25em; clear: left; }
118: dt + dt { margin-top: 0; }
119: dd dt { margin-top: 0.25em; margin-bottom: 0; }
120: dd p { margin-top: 0; }
121: dd dl + p { margin-top: 1em; }
122: dd table + p { margin-top: 1em; }
123: p + * > li, dd li { margin: 1em 0; }
124: dt, dfn { font-weight: bold; font-style: normal; }
125: i, em { font-style: italic; }
126: dt dfn { font-style: italic; }
127: pre, code { font-size: inherit; font-family: monospace; font-variant: normal; }
128: pre strong { color: black; font: inherit; font-weight: bold; background: yellow; }
129: pre em { font-weight: bolder; font-style: normal; }
130: @media screen { code { color: orangered; } code :link, code :visited { color: inherit; } }
131: var sub { vertical-align: bottom; font-size: smaller; position: relative; top: 0.1em; }
132: table { border-collapse: collapse; border-style: hidden hidden none hidden; }
133: table thead, table tbody { border-bottom: solid; }
134: table tbody th:first-child { border-left: solid; }
135: table tbody th { text-align: left; }
136: table td, table th { border-left: solid; border-right: solid; border-bottom: solid thin; vertical-align: top; padding: 0.2em; }
137: blockquote { margin: 0 0 0 2em; border: 0; padding: 0; font-style: italic; }
138:
139: .bad, .bad *:not(.XXX) { color: gray; border-color: gray; background: transparent; }
140: .matrix, .matrix td { border: none; text-align: right; }
141: .matrix { margin-left: 2em; }
142: .dice-example { border-collapse: collapse; border-style: hidden solid solid hidden; border-width: thin; margin-left: 3em; }
143: .dice-example caption { width: 30em; font-size: smaller; font-style: italic; padding: 0.75em 0; text-align: left; }
144: .dice-example td, .dice-example th { border: solid thin; width: 1.35em; height: 1.05em; text-align: center; padding: 0; }
145:
146: .toc dfn, h1 dfn, h2 dfn, h3 dfn, h4 dfn, h5 dfn, h6 dfn { font: inherit; }
147: img.extra, p.overview { float: right; }
148: pre.idl { border: solid thin; background: #EEEEEE; color: black; padding: 0.5em 1em; position: relative; }
149: pre.idl :link, pre.idl :visited { color: inherit; background: transparent; }
150: pre.idl::before { content: "IDL"; font: bold small sans-serif; padding: 0.5em; background: white; position: absolute; top: 0; margin: -1px 0 0 -4em; width: 1.5em; border: thin solid; border-radius: 0 0 0 0.5em }
151: pre.css { border: solid thin; background: #FFFFEE; color: black; padding: 0.5em 1em; }
152: pre.css:first-line { color: #AAAA50; }
153: dl.domintro { color: green; margin: 2em 0 2em 2em; padding: 0.5em 1em; border: none; background: #DDFFDD; }
154: hr + dl.domintro, div.impl + dl.domintro { margin-top: 2.5em; margin-bottom: 1.5em; }
155: dl.domintro dt, dl.domintro dt * { color: black; text-decoration: none; }
156: dl.domintro dd { margin: 0.5em 0 1em 2em; padding: 0; }
157: dl.domintro dd p { margin: 0.5em 0; }
158: dl.domintro:before { display: table; margin: -1em -0.5em -0.5em auto; width: auto; content: 'This box is non-normative. Implementation requirements are given below this box.'; color: black; font-style: italic; border: solid 2px; background: white; padding: 0 0.25em; }
159: dl.switch { padding-left: 2em; }
160: dl.switch > dt { text-indent: -1.5em; }
161: dl.switch > dt:before { content: '\21AA'; padding: 0 0.5em 0 0; display: inline-block; width: 1em; text-align: right; line-height: 0.5em; }
162: dl.triple { padding: 0 0 0 1em; }
163: dl.triple dt, dl.triple dd { margin: 0; display: inline }
164: dl.triple dt:after { content: ':'; }
165: dl.triple dd:after { content: '\A'; white-space: pre; }
166: .diff-old { text-decoration: line-through; color: silver; background: transparent; }
167: .diff-chg, .diff-new { text-decoration: underline; color: green; background: transparent; }
168: a .diff-new { border-bottom: 1px blue solid; }
169:
1.180 sruby 170: figure.diagrams { border: double black; background: white; padding: 1em; }
171: figure.diagrams img { display: block; margin: 1em auto; }
172:
1.1 mike 173: h2 { page-break-before: always; }
174: h1, h2, h3, h4, h5, h6 { page-break-after: avoid; }
175: h1 + h2, hr + h2.no-toc { page-break-before: auto; }
176:
177: p > span:not([title=""]):not([class="XXX"]):not([class="impl"]):not([class="note"]),
1.198 sruby 178: li > span:not([title=""]):not([class="XXX"]):not([class="impl"]):not([class="note"]) { border-bottom: solid #9999CC; }
1.1 mike 179:
180: div.head { margin: 0 0 1em; padding: 1em 0 0 0; }
181: div.head p { margin: 0; }
182: div.head h1 { margin: 0; }
183: div.head .logo { float: right; margin: 0 1em; }
184: div.head .logo img { border: none } /* remove border from top image */
185: div.head dl { margin: 1em 0; }
186: div.head p.copyright, div.head p.alt { font-size: x-small; font-style: oblique; margin: 0; }
187:
188: body > .toc > li { margin-top: 1em; margin-bottom: 1em; }
189: body > .toc.brief > li { margin-top: 0.35em; margin-bottom: 0.35em; }
190: body > .toc > li > * { margin-bottom: 0.5em; }
191: body > .toc > li > * > li > * { margin-bottom: 0.25em; }
192: .toc, .toc li { list-style: none; }
193:
194: .brief { margin-top: 1em; margin-bottom: 1em; line-height: 1.1; }
195: .brief li { margin: 0; padding: 0; }
196: .brief li p { margin: 0; padding: 0; }
197:
198: .category-list { margin-top: -0.75em; margin-bottom: 1em; line-height: 1.5; }
199: .category-list::before { content: '\21D2\A0'; font-size: 1.2em; font-weight: 900; }
200: .category-list li { display: inline; }
201: .category-list li:not(:last-child)::after { content: ', '; }
202: .category-list li > span, .category-list li > a { text-transform: lowercase; }
203: .category-list li * { text-transform: none; } /* don't affect <code> nested in <a> */
204:
205: .XXX { color: #E50000; background: white; border: solid red; padding: 0.5em; margin: 1em 0; }
206: .XXX > :first-child { margin-top: 0; }
207: p .XXX { line-height: 3em; }
208: .annotation { border: solid thin black; background: #0C479D; color: white; position: relative; margin: 8px 0 20px 0; }
209: .annotation:before { position: absolute; left: 0; top: 0; width: 100%; height: 100%; margin: 6px -6px -6px 6px; background: #333333; z-index: -1; content: ''; }
210: .annotation :link, .annotation :visited { color: inherit; }
211: .annotation :link:hover, .annotation :visited:hover { background: transparent; }
212: .annotation span { border: none ! important; }
213: .note { color: green; background: transparent; font-family: sans-serif; }
214: .warning { color: red; background: transparent; }
215: .note, .warning { font-weight: bolder; font-style: italic; }
216: .note em, .warning em, .note i, .warning i { font-style: normal; }
217: p.note, div.note { padding: 0.5em 2em; }
218: span.note { padding: 0 2em; }
219: .note p:first-child, .warning p:first-child { margin-top: 0; }
220: .note p:last-child, .warning p:last-child { margin-bottom: 0; }
221: .warning:before { font-style: normal; }
222: p.note:before { content: 'Note: '; }
223: p.warning:before { content: '\26A0 Warning! '; }
224:
225: .bookkeeping:before { display: block; content: 'Bookkeeping details'; font-weight: bolder; font-style: italic; }
226: .bookkeeping { font-size: 0.8em; margin: 2em 0; }
227: .bookkeeping p { margin: 0.5em 2em; display: list-item; list-style: square; }
228: .bookkeeping dt { margin: 0.5em 2em 0; }
229: .bookkeeping dd { margin: 0 3em 0.5em; }
230:
231: h4 { position: relative; z-index: 3; }
232: h4 + .element, h4 + div + .element { margin-top: -2.5em; padding-top: 2em; }
233: .element {
234: background: #EEEEFF;
235: color: black;
236: margin: 0 0 1em 0.15em;
237: padding: 0 1em 0.25em 0.75em;
238: border-left: solid #9999FF 0.25em;
239: position: relative;
240: z-index: 1;
241: }
242: .element:before {
243: position: absolute;
244: z-index: 2;
245: top: 0;
246: left: -1.15em;
247: height: 2em;
248: width: 0.9em;
249: background: #EEEEFF;
250: content: ' ';
251: border-style: none none solid solid;
252: border-color: #9999FF;
253: border-width: 0.25em;
254: }
255:
256: .example { display: block; color: #222222; background: #FCFCFC; border-left: double; margin-left: 2em; padding-left: 1em; }
257: td > .example:only-child { margin: 0 0 0 0.1em; }
258:
259: ul.domTree, ul.domTree ul { padding: 0 0 0 1em; margin: 0; }
260: ul.domTree li { padding: 0; margin: 0; list-style: none; position: relative; }
261: ul.domTree li li { list-style: none; }
262: ul.domTree li:first-child::before { position: absolute; top: 0; height: 0.6em; left: -0.75em; width: 0.5em; border-style: none none solid solid; content: ''; border-width: 0.1em; }
263: ul.domTree li:not(:last-child)::after { position: absolute; top: 0; bottom: -0.6em; left: -0.75em; width: 0.5em; border-style: none none solid solid; content: ''; border-width: 0.1em; }
264: ul.domTree span { font-style: italic; font-family: serif; }
265: ul.domTree .t1 code { color: purple; font-weight: bold; }
266: ul.domTree .t2 { font-style: normal; font-family: monospace; }
267: ul.domTree .t2 .name { color: black; font-weight: bold; }
268: ul.domTree .t2 .value { color: blue; font-weight: normal; }
269: ul.domTree .t3 code, .domTree .t4 code, .domTree .t5 code { color: gray; }
270: ul.domTree .t7 code, .domTree .t8 code { color: green; }
271: ul.domTree .t10 code { color: teal; }
272:
273: body.dfnEnabled dfn { cursor: pointer; }
274: .dfnPanel {
275: display: inline;
276: position: absolute;
277: z-index: 10;
278: height: auto;
279: width: auto;
280: padding: 0.5em 0.75em;
281: font: small sans-serif, Droid Sans Fallback;
282: background: #DDDDDD;
283: color: black;
284: border: outset 0.2em;
285: }
286: .dfnPanel * { margin: 0; padding: 0; font: inherit; text-indent: 0; }
287: .dfnPanel :link, .dfnPanel :visited { color: black; }
288: .dfnPanel p { font-weight: bolder; }
289: .dfnPanel * + p { margin-top: 0.25em; }
290: .dfnPanel li { list-style-position: inside; }
291:
292: #configUI { position: absolute; z-index: 20; top: 10em; right: 1em; width: 11em; font-size: small; }
293: #configUI p { margin: 0.5em 0; padding: 0.3em; background: #EEEEEE; color: black; border: inset thin; }
294: #configUI p label { display: block; }
295: #configUI #updateUI, #configUI .loginUI { text-align: center; }
296: #configUI input[type=button] { display: block; margin: auto; }
297:
298: fieldset { margin: 1em; padding: 0.5em 1em; }
299: fieldset > legend + * { margin-top: 0; }
300: fieldset > :last-child { margin-bottom: 0; }
301: fieldset p { margin: 0.5em 0; }
302:
1.205 sruby 303: </style><link href="http://www.w3.org/StyleSheets/TR/W3C-ED" rel="stylesheet" type="text/css"><script>
1.1 mike 304: function getCookie(name) {
305: var params = location.search.substr(1).split("&");
306: for (var index = 0; index < params.length; index++) {
307: if (params[index] == name)
308: return "1";
309: var data = params[index].split("=");
310: if (data[0] == name)
311: return unescape(data[1]);
312: }
313: var cookies = document.cookie.split("; ");
314: for (var index = 0; index < cookies.length; index++) {
315: var data = cookies[index].split("=");
316: if (data[0] == name)
317: return unescape(data[1]);
318: }
319: return null;
320: }
1.202 sruby 321: </script><link href="forms.html" rel="prev" title="4.10 Forms">
322: <link href="index.html#contents" rel="contents" title="Table of contents">
323: <link href="the-fieldset-element.html" rel="next" title="4.10.4 The fieldset element">
324: <body class="split chapter" onload="fixBrokenLink();"><div class="head" id="head">
1.1 mike 325: <p><a href="http://www.w3.org/"><img alt="W3C" height="48" src="http://www.w3.org/Icons/w3c_home" width="72"></a></p>
326:
327: <h1>HTML5</h1>
1.195 sruby 328: <h2 class="no-num no-toc" id="a-vocabulary-and-associated-apis-for-html-and-xhtml">A vocabulary and associated APIs for HTML and XHTML</h2>
1.211 ! sruby 329: <h2 class="no-num no-toc" id="editor's-draft-date-1-january-1970">Editor's Draft 11 November 2012</h2>
1.85 mike 330: </div>
1.198 sruby 331:
332:
1.202 sruby 333: <nav class="prev_next">
334: <a href="forms.html">← 4.10 Forms</a> –
335: <a href="index.html#contents">Table of contents</a> –
336: <a href="the-fieldset-element.html">4.10.4 The fieldset element →</a>
337: </nav>
1.1 mike 338:
1.85 mike 339: <h4 id="the-form-element"><span class="secno">4.10.3 </span>The <dfn><code>form</code></dfn> element</h4>
340:
341: <dl class="element"><dt><a href="element-definitions.html#element-dfn-categories" title="element-dfn-categories">Categories</a>:</dt>
1.159 sruby 342: <dd><a href="content-models.html#flow-content-1">Flow content</a>.</dd>
343: <dd><a href="content-models.html#palpable-content-0">Palpable content</a>.</dd>
1.25 mike 344: <dt><a href="element-definitions.html#element-dfn-contexts" title="element-dfn-contexts">Contexts in which this element can be used</a>:</dt>
1.159 sruby 345: <dd>Where <a href="content-models.html#flow-content-1">flow content</a> is expected.</dd>
1.25 mike 346: <dt><a href="element-definitions.html#element-dfn-content-model" title="element-dfn-content-model">Content model</a>:</dt>
1.159 sruby 347: <dd><a href="content-models.html#flow-content-1">Flow content</a>, but with no <code><a href="#the-form-element">form</a></code> element descendants.</dd>
1.25 mike 348: <dt><a href="element-definitions.html#element-dfn-attributes" title="element-dfn-attributes">Content attributes</a>:</dt>
1.1 mike 349: <dd><a href="global-attributes.html#global-attributes">Global attributes</a></dd>
350: <dd><code title="attr-form-accept-charset"><a href="#attr-form-accept-charset">accept-charset</a></code></dd>
1.159 sruby 351: <dd><code title="attr-fs-action"><a href="form-submission.html#attr-fs-action">action</a></code></dd>
1.1 mike 352: <dd><code title="attr-form-autocomplete"><a href="#attr-form-autocomplete">autocomplete</a></code></dd>
1.159 sruby 353: <dd><code title="attr-fs-enctype"><a href="form-submission.html#attr-fs-enctype">enctype</a></code></dd>
354: <dd><code title="attr-fs-method"><a href="form-submission.html#attr-fs-method">method</a></code></dd>
1.1 mike 355: <dd><code title="attr-form-name"><a href="#attr-form-name">name</a></code></dd>
1.159 sruby 356: <dd><code title="attr-fs-novalidate"><a href="form-submission.html#attr-fs-novalidate">novalidate</a></code></dd>
357: <dd><code title="attr-fs-target"><a href="form-submission.html#attr-fs-target">target</a></code></dd>
358: <dt><a href="element-definitions.html#element-dfn-dom" title="element-dfn-dom">DOM interface</a>:</dt><!--TOPIC:DOM APIs-->
1.1 mike 359: <dd>
360: <pre class="idl">[OverrideBuiltins]
361: interface <dfn id="htmlformelement">HTMLFormElement</dfn> : <a href="elements.html#htmlelement">HTMLElement</a> {
362: attribute DOMString <a href="#dom-form-acceptcharset" title="dom-form-acceptCharset">acceptCharset</a>;
1.159 sruby 363: attribute DOMString <a href="form-submission.html#dom-fs-action" title="dom-fs-action">action</a>;
1.1 mike 364: attribute DOMString <a href="#dom-form-autocomplete" title="dom-form-autocomplete">autocomplete</a>;
1.159 sruby 365: attribute DOMString <a href="form-submission.html#dom-fs-enctype" title="dom-fs-enctype">enctype</a>;
366: attribute DOMString <a href="form-submission.html#dom-fs-encoding" title="dom-fs-encoding">encoding</a>;<!-- historical artefact -->
367: attribute DOMString <a href="form-submission.html#dom-fs-method" title="dom-fs-method">method</a>;
1.1 mike 368: attribute DOMString <a href="#dom-form-name" title="dom-form-name">name</a>;
1.159 sruby 369: attribute boolean <a href="form-submission.html#dom-fs-novalidate" title="dom-fs-noValidate">noValidate</a>;
370: attribute DOMString <a href="form-submission.html#dom-fs-target" title="dom-fs-target">target</a>;
1.1 mike 371:
1.159 sruby 372: readonly attribute <a href="common-dom-interfaces.html#htmlformcontrolscollection-0">HTMLFormControlsCollection</a> <a href="#dom-form-elements" title="dom-form-elements">elements</a>;
1.1 mike 373: readonly attribute long <a href="#dom-form-length" title="dom-form-length">length</a>;
374: <a href="#dom-form-item" title="dom-form-item">getter</a> <a href="infrastructure.html#element">Element</a> (unsigned long index);
375: <a href="#dom-form-nameditem" title="dom-form-namedItem">getter</a> object (DOMString name);
376:
377: void <a href="#dom-form-submit" title="dom-form-submit">submit</a>();
378: void <a href="#dom-form-reset" title="dom-form-reset">reset</a>();
379: boolean <a href="#dom-form-checkvalidity" title="dom-form-checkValidity">checkValidity</a>();
380: };</pre>
381: </dd>
1.203 sruby 382: </dl><!--TOPIC:HTML--><p>The <code><a href="#the-form-element">form</a></code> element <a href="rendering.html#represents">represents</a> a
1.1 mike 383: collection of <a href="forms.html#form-associated-element" title="form-associated element">form-associated
384: elements</a>, some of which can represent editable values that
1.85 mike 385: can be submitted to a server for processing.</p>
386:
387: <p>The <dfn id="attr-form-accept-charset" title="attr-form-accept-charset"><code>accept-charset</code></dfn>
1.1 mike 388: attribute gives the character encodings that are to be used for the
389: submission. If specified, the value must be an <a href="common-microsyntaxes.html#ordered-set-of-unique-space-separated-tokens">ordered set of
390: unique space-separated tokens</a> that are <a href="infrastructure.html#ascii-case-insensitive">ASCII
391: case-insensitive</a>, and each token must be an <a href="infrastructure.html#ascii-case-insensitive">ASCII
392: case-insensitive</a> match for the <a href="infrastructure.html#preferred-mime-name">preferred MIME
393: name</a> of an <a href="infrastructure.html#ascii-compatible-character-encoding">ASCII-compatible character encoding</a>.
1.203 sruby 394: <a href="references.html#refsIANACHARSET">[IANACHARSET]</a></p>
1.85 mike 395:
396: <p>The <dfn id="attr-form-name" title="attr-form-name"><code>name</code></dfn> attribute
1.1 mike 397: represents the <code><a href="#the-form-element">form</a></code>'s name within the <code title="dom-document-forms"><a href="dom.html#dom-document-forms">forms</a></code> collection. The value must
398: not be the empty string, and the value must be unique amongst the
399: <code><a href="#the-form-element">form</a></code> elements in the <code title="dom-document-forms"><a href="dom.html#dom-document-forms">forms</a></code> collection that it is in, if
1.85 mike 400: any.</p>
401:
402: <p>The <dfn id="attr-form-autocomplete" title="attr-form-autocomplete"><code>autocomplete</code></dfn>
1.1 mike 403: attribute is an <a href="common-microsyntaxes.html#enumerated-attribute">enumerated attribute</a>. The attribute has
404: two states. The <code title="attr-form-autocomplete-on">on</code>
405: keyword maps to the <dfn id="attr-form-autocomplete-on-state" title="attr-form-autocomplete-on-state">on</dfn> state, and the
406: <code title="attr-form-autocomplete-off">off</code> keyword maps to
407: the <dfn id="attr-form-autocomplete-off-state" title="attr-form-autocomplete-off-state">off</dfn>
408: state. The attribute may also be omitted. The <i>missing value
409: default</i> is the <a href="#attr-form-autocomplete-on-state" title="attr-form-autocomplete-on-state">on</a> state. The <a href="#attr-form-autocomplete-off-state" title="attr-form-autocomplete-off-state">off</a> state indicates
410: that by default, <code><a href="the-input-element.html#the-input-element">input</a></code> elements in the form will have
411: their <a href="common-input-element-attributes.html#resulting-autocompletion-state">resulting autocompletion state</a> set to <i title="">off</i>; the <a href="#attr-form-autocomplete-on-state" title="attr-form-autocomplete-on-state">on</a> state indicates
412: that by default, <code><a href="the-input-element.html#the-input-element">input</a></code> elements in the form will have
1.85 mike 413: their <a href="common-input-element-attributes.html#resulting-autocompletion-state">resulting autocompletion state</a> set to <i title="">on</i>.</p>
414:
1.159 sruby 415: <p>The <code title="attr-fs-action"><a href="form-submission.html#attr-fs-action">action</a></code>, <code title="attr-fs-enctype"><a href="form-submission.html#attr-fs-enctype">enctype</a></code>, <code title="attr-fs-method"><a href="form-submission.html#attr-fs-method">method</a></code>, <code title="attr-fs-novalidate"><a href="form-submission.html#attr-fs-novalidate">novalidate</a></code>, and <code title="attr-fs-target"><a href="form-submission.html#attr-fs-target">target</a></code> attributes are <a href="form-submission.html#attributes-for-form-submission">attributes
1.85 mike 416: for form submission</a>.</p>
417:
1.159 sruby 418: <!--TOPIC:DOM APIs-->
1.85 mike 419: <dl class="domintro"><dt><var title="">form</var> . <code title="dom-form-elements"><a href="#dom-form-elements">elements</a></code></dt>
1.1 mike 420:
421: <dd>
422:
423: <p>Returns an <code><a href="infrastructure.html#htmlcollection">HTMLCollection</a></code> of the form controls in
424: the form (excluding image buttons for historical reasons).</p>
425:
426: </dd>
427:
428: <dt><var title="">form</var> . <code title="dom-form-length"><a href="#dom-form-length">length</a></code></dt>
429:
430: <dd>
431:
432: <p>Returns the number of form controls in the form (excluding
433: image buttons for historical reasons).</p>
434:
435: </dd>
436:
437: <dt><var title="">form</var>[<var title="">index</var>]</dt>
438: <dt><var title="">form</var>(<var title="">index</var>)</dt>
439:
440: <dd>
441:
442: <p>Returns the <var title="">index</var>th element in the form
443: (excluding image buttons for historical reasons).</p>
444:
445: </dd>
446:
447: <dt><var title="">form</var>[<var title="">name</var>]</dt>
448: <dt><var title="">form</var>(<var title="">name</var>)</dt>
449:
450: <dd>
451:
452: <p>Returns the form control (or, if there are several, a
1.123 mike 453: <code><a href="common-dom-interfaces.html#radionodelist">RadioNodeList</a></code> of the form controls) in the form with
454: the given <a href="infrastructure.html#concept-id" title="concept-id">ID</a> or <code title="attr-fe-name"><a href="attributes-common-to-form-controls.html#attr-fe-name">name</a></code> (excluding image buttons for
1.1 mike 455: historical reasons); or, if there are none, returns the
456: <code><a href="the-img-element.html#the-img-element">img</a></code> element with the given ID.</p>
457:
458: <p>Once an element has been referenced using a particular name,
459: that name will continue being available as a way to reference that
460: element in this method, even if the element's actual <a href="infrastructure.html#concept-id" title="concept-id">ID</a> or <code title="attr-fe-name"><a href="attributes-common-to-form-controls.html#attr-fe-name">name</a></code> changes, for as long as the
461: element remains in the <code><a href="dom.html#document">Document</a></code>.</p>
462:
463: <p>If there are multiple matching items, then a
1.123 mike 464: <code><a href="common-dom-interfaces.html#radionodelist">RadioNodeList</a></code> object containing all those elements is
1.1 mike 465: returned.</p>
466:
467: </dd>
468:
469: <dt><var title="">form</var> . <code title="dom-form-submit"><a href="#dom-form-submit">submit</a></code>()</dt>
470:
471: <dd>
472:
473: <p>Submits the form.</p>
474:
475: </dd>
476:
477: <dt><var title="">form</var> . <code title="dom-form-reset"><a href="#dom-form-reset">reset</a></code>()</dt>
478:
479: <dd>
480:
481: <p>Resets the form.</p>
482:
483: </dd>
484:
485: <dt><var title="">form</var> . <code title="dom-form-checkValidity"><a href="#dom-form-checkvalidity">checkValidity</a></code>()</dt>
486:
487: <dd>
488:
489: <p>Returns true if the form's controls are all valid; otherwise,
490: returns false.</p>
491:
492: </dd>
493:
494: </dl><div class="impl">
495:
496: <p>The <dfn id="dom-form-autocomplete" title="dom-form-autocomplete"><code>autocomplete</code></dfn> IDL
497: attribute must <a href="common-dom-interfaces.html#reflect">reflect</a> the content attribute of the
498: same name, <a href="common-dom-interfaces.html#limited-to-only-known-values">limited to only known values</a>.</p>
499:
500: <p>The <dfn id="dom-form-name" title="dom-form-name"><code>name</code></dfn> IDL
501: attribute must <a href="common-dom-interfaces.html#reflect">reflect</a> the content attribute of the
502: same name.</p>
503:
504: <p>The <dfn id="dom-form-acceptcharset" title="dom-form-acceptCharset"><code>acceptCharset</code></dfn> IDL
505: attribute must <a href="common-dom-interfaces.html#reflect">reflect</a> the <code title="attr-form-accept-charset"><a href="#attr-form-accept-charset">accept-charset</a></code> content
506: attribute.</p>
507:
508: <hr><p>The <dfn id="dom-form-elements" title="dom-form-elements"><code>elements</code></dfn>
1.159 sruby 509: IDL attribute must return an <code><a href="common-dom-interfaces.html#htmlformcontrolscollection-0">HTMLFormControlsCollection</a></code>
1.124 mike 510: rooted at the <code><a href="dom.html#document">Document</a></code> node while the <code><a href="#the-form-element">form</a></code>
511: element is <a href="infrastructure.html#in-a-document">in a <code>Document</code></a> and rooted at the
512: <code><a href="#the-form-element">form</a></code> element itself when it is not, whose filter
513: matches <a href="forms.html#category-listed" title="category-listed">listed elements</a> whose
514: <a href="association-of-controls-and-forms.html#form-owner">form owner</a> is the <code><a href="#the-form-element">form</a></code> element, with the
1.159 sruby 515: exception of <code><a href="the-input-element.html#the-input-element">input</a></code> elements whose <code title="attr-input-type"><a href="the-input-element.html#attr-input-type">type</a></code> attribute is in the <a href="states-of-the-type-attribute.html#image-button-state-(type=image)" title="attr-input-type-image">Image Button</a> state, which must,
1.1 mike 516: for historical reasons, be excluded from this particular
517: collection.</p>
518:
519: <p>The <dfn id="dom-form-length" title="dom-form-length"><code>length</code></dfn> IDL
520: attribute must return the number of nodes <a href="infrastructure.html#represented-by-the-collection" title="represented
521: by the collection">represented</a> by the <code title="dom-form-elements"><a href="#dom-form-elements">elements</a></code> collection.</p>
522:
523: <p>The <a href="infrastructure.html#supported-property-indices">supported property indices</a> at any instant are
524: the indices supported by the object returned by the <code title="dom-form-elements"><a href="#dom-form-elements">elements</a></code> attribute at that
525: instant.</p>
526:
527: <p>When a <code><a href="#the-form-element">form</a></code> element is <dfn id="dom-form-item" title="dom-form-item">indexed for indexed property retrieval</dfn>,
528: the user agent must return the value returned by the <code title="dom-HTMLFormControlsCollection-item">item</code> method on
529: the <code title="dom-form-elements"><a href="#dom-form-elements">elements</a></code> collection, when
530: invoked with the given index as its argument.</p>
531:
1.159 sruby 532: <hr><!-- Welcome to crazy town. Population: The Web. --><p>Each <code><a href="#the-form-element">form</a></code> element has a mapping of names to elements
1.1 mike 533: called the <dfn id="past-names-map">past names map</dfn>. It is used to persist names of
534: controls even when they change names.</p>
535:
536: <p>The <a href="infrastructure.html#supported-property-names">supported property names</a> consist of the values
537: of all the <code title="attr-id"><a href="global-attributes.html#the-id-attribute">id</a></code> and <code title="attr-fe-name"><a href="attributes-common-to-form-controls.html#attr-fe-name">name</a></code> attributes of all the <a href="forms.html#category-listed" title="category-listed">listed elements</a> and <code><a href="the-img-element.html#the-img-element">img</a></code>
538: elements that are descendants of the <code><a href="#the-form-element">form</a></code> element, and
539: all the names currently in the <a href="#past-names-map">past names map</a>.</p>
540:
541: <p>When a <code><a href="#the-form-element">form</a></code> element is <dfn id="dom-form-nameditem" title="dom-form-namedItem">indexed for named property
542: retrieval</dfn>, the user agent must run the following steps:</p>
543:
544: <ol><li><p>Let <var title="">candidates</var> be a <a href="infrastructure.html#live">live</a>
1.123 mike 545: <code><a href="common-dom-interfaces.html#radionodelist">RadioNodeList</a></code> object containing all the <a href="forms.html#category-listed" title="category-listed">listed elements</a> that are descendants
1.202 sruby 546: of the <code><a href="#the-form-element">form</a></code> element and that have either an <code title="attr-id"><a href="global-attributes.html#the-id-attribute">id</a></code> attribute or a <code title="attr-fe-name"><a href="attributes-common-to-form-controls.html#attr-fe-name">name</a></code> attribute equal to <var title="">name</var>, in <a href="infrastructure.html#tree-order">tree order</a>.</li>
1.1 mike 547:
548: <li><p>If <var title="">candidates</var> is empty, let <var title="">candidates</var> be a <a href="infrastructure.html#live">live</a>
1.123 mike 549: <code><a href="common-dom-interfaces.html#radionodelist">RadioNodeList</a></code> object containing all the
550: <code><a href="the-img-element.html#the-img-element">img</a></code> elements that are descendants of the
1.203 sruby 551: <code><a href="#the-form-element">form</a></code> element and that have either an <code title="attr-id"><a href="global-attributes.html#the-id-attribute">id</a></code> attribute or a <code title="attr-img-name"><a href="obsolete.html#attr-img-name">name</a></code> attribute equal to <var title="">name</var>, in <a href="infrastructure.html#tree-order">tree order</a>.</li>
1.1 mike 552:
553: <li><p>If <var title="">candidates</var> is empty, <var title="">name</var> is the name of one of the entries in the
554: <code><a href="#the-form-element">form</a></code> element's <a href="#past-names-map">past names map</a>: return the
555: object associated with <var title="">name</var> in that
1.202 sruby 556: map.</li>
1.1 mike 557:
558: <li><p>If <var title="">candidates</var> contains more than one
559: node, return <var title="">candidates</var> and abort these
1.202 sruby 560: steps.</li>
1.1 mike 561:
562: <li><p>Otherwise, <var title="">candidates</var> contains exactly
563: one node. Add a mapping from <var title="">name</var> to the node
564: in <var title="">candidates</var> in the <code><a href="#the-form-element">form</a></code> element's
565: <a href="#past-names-map">past names map</a>, replacing the previous entry with the
1.202 sruby 566: same name, if any.</li>
1.1 mike 567:
1.202 sruby 568: <li><p>Return the node in <var title="">candidates</var>.</li>
1.1 mike 569:
570: </ol><p>If an element listed in the <code><a href="#the-form-element">form</a></code> element's <a href="#past-names-map">past
571: names map</a> is removed from the <code><a href="dom.html#document">Document</a></code>, then its
572: entries must be removed from the map.</p>
573:
1.159 sruby 574: <!--
575: This ridiculous setup is intended to do as much of the right thing
576: while still supporting code written to work in IE7. IE versions
577: prior to IE8 do not update the names on the <form> element
578: collection to match new names when elements are renamed, and there
579: are enough pages that rename elements and then access them by
580: their old name that we have to support this.
581:
582: But we still want to expose them using the new names, so as far as
583: possible we pretend the legacy names aren't there except if
584: there's no other element actually named that way.
585:
586: Removing the element did remove the legacy name in IE7:
587: http://software.hixie.ch/utilities/js/live-dom-viewer/?%3C!DOCTYPE%20html%3E...%3Cform%20action%3D%22%2F%22%3E%3Cinput%20name%3Dsubmit%3E%3C%2Fform%3E%0A%3Cscript%3E%0A%20w(document.forms%5B0%5D.submit)%3B%0A%20w(document.forms%5B0%5D.removeChild(document.getElementsByTagName('input')%5B0%5D))%3B%0A%20w(document.forms%5B0%5D.length)%3B%0A%20try%20%7B%20document.forms%5B0%5D.submit()%3B%20%7D%20catch%20(e)%20%20%7B%20w(e.message)%20%7D%0A%3C%2Fscript%3E
588:
589: There's no interop on what happens when the name was originally a
590: duplicate name, so we don't persist such accesses - at the time
591: of writing, Safari returned the first element, Firefox returned
592: null (as we do), and IE7 returned the original collection:
593: http://software.hixie.ch/utilities/js/live-dom-viewer/?%3C!DOCTYPE%20html%3E...%3Cform%20action%3D%22%2F%22%3E%3Cinput%20name%3Da%20id%3Dfirst%3E%3Cinput%20name%3Da%20id%3Dsecond%3E%3C%2Fform%3E%0A%3Cscript%3E%0A%20w%28document.forms[0].a%29%3B%0A%20document.getElementsByTagName%28%27input%27%29[0].name%20%3D%20%27b%27%3B%0A%20document.getElementsByTagName%28%27input%27%29[1].name%20%3D%20%27b%27%3B%0A%20w%28document.forms[0].length%29%3B%0A%20w%28document.forms[0].a.id%29%3B%0A%3C%2Fscript%3E
594:
595: In addition, the <img> fallback nonsense is similarly here for
596: legacy reasons. As is the exclusion of <input type=image>.
1.4 mike 597:
1.159 sruby 598: Also, check this out:
599: http://software.hixie.ch/utilities/js/live-dom-viewer/saved/1220
600:
601: -->
602:
603: <!-- Now leaving crazy town. -->
1.1 mike 604:
605: <hr><p>The <dfn id="dom-form-submit" title="dom-form-submit"><code>submit()</code></dfn>
1.203 sruby 606: method, when invoked, must <a href="constraints.html#concept-form-submit" title="concept-form-submit">submit</a> the <code><a href="#the-form-element">form</a></code>
1.1 mike 607: element from the <code><a href="#the-form-element">form</a></code> element itself, with the <var title="">submitted from <code title="dom-form-submit"><a href="#dom-form-submit">submit()</a></code> method</var> flag set.</p>
608:
609: <p>The <dfn id="dom-form-reset" title="dom-form-reset"><code>reset()</code></dfn>
610: method, when invoked, must run the following steps:</p>
611:
612: <ol><li><p>If the <code><a href="#the-form-element">form</a></code> element is marked as <i><a href="#locked-for-reset">locked for
1.202 sruby 613: reset</a></i>, then abort these steps.</li>
1.1 mike 614:
615: <li><p>Mark the <code><a href="#the-form-element">form</a></code> element as <dfn id="locked-for-reset">locked for
1.202 sruby 616: reset</dfn>.</li>
1.1 mike 617:
1.203 sruby 618: <li><p><a href="constraints.html#concept-form-reset" title="concept-form-reset">Reset</a> the
1.202 sruby 619: <code><a href="#the-form-element">form</a></code> element.</li>
1.1 mike 620:
621: <li><p>Unmark the <code><a href="#the-form-element">form</a></code> element as <i><a href="#locked-for-reset">locked for
1.202 sruby 622: reset</a></i>.</li>
1.1 mike 623:
624: </ol><p>If the <dfn id="dom-form-checkvalidity" title="dom-form-checkValidity"><code>checkValidity()</code></dfn>
1.203 sruby 625: method is invoked, the user agent must <a href="constraints.html#statically-validate-the-constraints">statically validate the
1.1 mike 626: constraints</a> of the <code><a href="#the-form-element">form</a></code> element, and return true
627: if the constraint validation return a <i>positive</i> result, and
628: false if it returned a <i>negative</i> result.</p>
629:
1.85 mike 630: </div>
1.159 sruby 631: <!--TOPIC:HTML-->
1.85 mike 632:
633: <div class="example">
1.1 mike 634:
635: <p>This example shows two search forms:</p>
636:
637: <pre><form action="http://www.google.com/search" method="get">
638: <label>Google: <input type="search" name="q"></label> <input type="submit" value="Search...">
639: </form>
640: <form action="http://www.bing.com/search" method="get">
641: <label>Bing: <input type="search" name="q"></label> <input type="submit" value="Search...">
642: </form></pre>
643:
1.85 mike 644: </div>
645:
646:
647:
648:
1.202 sruby 649:
Webmaster