Annotation of html5/spec/common-input-element-attributes.html, revision 1.7
1.1 mike 1: <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN">
2: <!DOCTYPE html>
3: <!-- when publishing, change bits marked ZZZ --><html lang="en-US-x-Hixie" class="split chapter"><head><title>4.10.7.2 Common input element attributes — HTML5 </title><style type="text/css">
4: pre { margin-left: 2em; white-space: pre-wrap; }
5: h2 { margin: 3em 0 1em 0; }
6: h3 { margin: 2.5em 0 1em 0; }
7: h4 { margin: 2.5em 0 0.75em 0; }
8: h5, h6 { margin: 2.5em 0 1em; }
9: h1 + h2, h1 + h2 + h2 { margin: 0.75em 0 0.75em; }
10: h2 + h3, h3 + h4, h4 + h5, h5 + h6 { margin-top: 0.5em; }
11: p { margin: 1em 0; }
12: hr:not(.top) { display: block; background: none; border: none; padding: 0; margin: 2em 0; height: auto; }
13: dl, dd { margin-top: 0; margin-bottom: 0; }
14: dt { margin-top: 0.75em; margin-bottom: 0.25em; clear: left; }
15: dt + dt { margin-top: 0; }
16: dd dt { margin-top: 0.25em; margin-bottom: 0; }
17: dd p { margin-top: 0; }
18: dd dl + p { margin-top: 1em; }
19: dd table + p { margin-top: 1em; }
20: p + * > li, dd li { margin: 1em 0; }
21: dt, dfn { font-weight: bold; font-style: normal; }
22: dt dfn { font-style: italic; }
23: pre, code { font-size: inherit; font-family: monospace; font-variant: normal; }
24: pre strong { color: black; font: inherit; font-weight: bold; background: yellow; }
25: pre em { font-weight: bolder; font-style: normal; }
26: @media screen { code { color: orangered; } code :link, code :visited { color: inherit; } }
27: var sub { vertical-align: bottom; font-size: smaller; position: relative; top: 0.1em; }
28: table { border-collapse: collapse; border-style: hidden hidden none hidden; }
29: table thead, table tbody { border-bottom: solid; }
30: table tbody th:first-child { border-left: solid; }
31: table tbody th { text-align: left; }
32: table td, table th { border-left: solid; border-right: solid; border-bottom: solid thin; vertical-align: top; padding: 0.2em; }
33: blockquote { margin: 0 0 0 2em; border: 0; padding: 0; font-style: italic; }
34:
35: .bad, .bad *:not(.XXX) { color: gray; border-color: gray; background: transparent; }
36: .matrix, .matrix td { border: none; text-align: right; }
37: .matrix { margin-left: 2em; }
38: .dice-example { border-collapse: collapse; border-style: hidden solid solid hidden; border-width: thin; margin-left: 3em; }
39: .dice-example caption { width: 30em; font-size: smaller; font-style: italic; padding: 0.75em 0; text-align: left; }
40: .dice-example td, .dice-example th { border: solid thin; width: 1.35em; height: 1.05em; text-align: center; padding: 0; }
41:
42: .toc dfn, h1 dfn, h2 dfn, h3 dfn, h4 dfn, h5 dfn, h6 dfn { font: inherit; }
43: img.extra { float: right; }
44: pre.idl { border: solid thin; background: #EEEEEE; color: black; padding: 0.5em 1em; }
45: pre.idl :link, pre.idl :visited { color: inherit; background: transparent; }
46: pre.css { border: solid thin; background: #FFFFEE; color: black; padding: 0.5em 1em; }
47: pre.css:first-line { color: #AAAA50; }
48: dl.domintro { color: green; margin: 2em 0 2em 2em; padding: 0.5em 1em; border: none; background: #DDFFDD; }
49: hr + dl.domintro, div.impl + dl.domintro { margin-top: 2.5em; margin-bottom: 1.5em; }
50: dl.domintro dt, dl.domintro dt * { color: black; text-decoration: none; }
51: dl.domintro dd { margin: 0.5em 0 1em 2em; padding: 0; }
52: dl.domintro dd p { margin: 0.5em 0; }
53: dl.switch { padding-left: 2em; }
54: dl.switch > dt { text-indent: -1.5em; }
55: dl.switch > dt:before { content: '\21AA'; padding: 0 0.5em 0 0; display: inline-block; width: 1em; text-align: right; line-height: 0.5em; }
56: dl.triple { padding: 0 0 0 1em; }
57: dl.triple dt, dl.triple dd { margin: 0; display: inline }
58: dl.triple dt:after { content: ':'; }
59: dl.triple dd:after { content: '\A'; white-space: pre; }
60: .diff-old { text-decoration: line-through; color: silver; background: transparent; }
61: .diff-chg, .diff-new { text-decoration: underline; color: green; background: transparent; }
62: a .diff-new { border-bottom: 1px blue solid; }
63:
64: h2 { page-break-before: always; }
65: h1, h2, h3, h4, h5, h6 { page-break-after: avoid; }
66: h1 + h2, hr + h2.no-toc { page-break-before: auto; }
67:
68: p > span:not([title=""]):not([class="XXX"]):not([class="impl"]), li > span:not([title=""]):not([class="XXX"]):not([class="impl"]) { border-bottom: solid #9999CC; }
69:
70: div.head { margin: 0 0 1em; padding: 1em 0 0 0; }
71: div.head p { margin: 0; }
72: div.head h1 { margin: 0; }
73: div.head .logo { float: right; margin: 0 1em; }
74: div.head .logo img { border: none } /* remove border from top image */
75: div.head dl { margin: 1em 0; }
76: div.head p.copyright, div.head p.alt { font-size: x-small; font-style: oblique; margin: 0; }
77:
78: body > .toc > li { margin-top: 1em; margin-bottom: 1em; }
79: body > .toc.brief > li { margin-top: 0.35em; margin-bottom: 0.35em; }
80: body > .toc > li > * { margin-bottom: 0.5em; }
81: body > .toc > li > * > li > * { margin-bottom: 0.25em; }
82: .toc, .toc li { list-style: none; }
83:
84: .brief { margin-top: 1em; margin-bottom: 1em; line-height: 1.1; }
85: .brief li { margin: 0; padding: 0; }
86: .brief li p { margin: 0; padding: 0; }
87:
88: .category-list { margin-top: -0.75em; margin-bottom: 1em; line-height: 1.5; }
89: .category-list::before { content: '\21D2\A0'; font-size: 1.2em; font-weight: 900; }
90: .category-list li { display: inline; }
91: .category-list li:not(:last-child)::after { content: ', '; }
92: .category-list li > span, .category-list li > a { text-transform: lowercase; }
93: .category-list li * { text-transform: none; } /* don't affect <code> nested in <a> */
94:
95: .XXX { color: #E50000; background: white; border: solid red; padding: 0.5em; margin: 1em 0; }
96: .XXX > :first-child { margin-top: 0; }
97: p .XXX { line-height: 3em; }
98: .annotation { border: solid thin black; background: #0C479D; color: white; position: relative; margin: 8px 0 20px 0; }
99: .annotation:before { position: absolute; left: 0; top: 0; width: 100%; height: 100%; margin: 6px -6px -6px 6px; background: #333333; z-index: -1; content: ''; }
100: .annotation :link, .annotation :visited { color: inherit; }
101: .annotation :link:hover, .annotation :visited:hover { background: transparent; }
102: .annotation span { border: none ! important; }
103: .note { color: green; background: transparent; font-family: sans-serif; }
104: .warning { color: red; background: transparent; }
105: .note, .warning { font-weight: bolder; font-style: italic; }
106: p.note, div.note { padding: 0.5em 2em; }
107: span.note { padding: 0 2em; }
108: .note p:first-child, .warning p:first-child { margin-top: 0; }
109: .note p:last-child, .warning p:last-child { margin-bottom: 0; }
110: .warning:before { font-style: normal; }
111: p.note:before { content: 'Note: '; }
112: p.warning:before { content: '\26A0 Warning! '; }
113:
114: .bookkeeping:before { display: block; content: 'Bookkeeping details'; font-weight: bolder; font-style: italic; }
115: .bookkeeping { font-size: 0.8em; margin: 2em 0; }
116: .bookkeeping p { margin: 0.5em 2em; display: list-item; list-style: square; }
117:
118: h4 { position: relative; z-index: 3; }
119: h4 + .element, h4 + div + .element { margin-top: -2.5em; padding-top: 2em; }
120: .element {
121: background: #EEEEFF;
122: color: black;
123: margin: 0 0 1em 0.15em;
124: padding: 0 1em 0.25em 0.75em;
125: border-left: solid #9999FF 0.25em;
126: position: relative;
127: z-index: 1;
128: }
129: .element:before {
130: position: absolute;
131: z-index: 2;
132: top: 0;
133: left: -1.15em;
134: height: 2em;
135: width: 0.9em;
136: background: #EEEEFF;
137: content: ' ';
138: border-style: none none solid solid;
139: border-color: #9999FF;
140: border-width: 0.25em;
141: }
142:
143: .example { display: block; color: #222222; background: #FCFCFC; border-left: double; margin-left: 2em; padding-left: 1em; }
144: td > .example:only-child { margin: 0 0 0 0.1em; }
145:
146: ul.domTree, ul.domTree ul { padding: 0 0 0 1em; margin: 0; }
147: ul.domTree li { padding: 0; margin: 0; list-style: none; position: relative; }
148: ul.domTree li li { list-style: none; }
149: 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; }
150: 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; }
151: ul.domTree span { font-style: italic; font-family: serif; }
152: ul.domTree .t1 code { color: purple; font-weight: bold; }
153: ul.domTree .t2 { font-style: normal; font-family: monospace; }
154: ul.domTree .t2 .name { color: black; font-weight: bold; }
155: ul.domTree .t2 .value { color: blue; font-weight: normal; }
156: ul.domTree .t3 code, .domTree .t4 code, .domTree .t5 code { color: gray; }
157: ul.domTree .t7 code, .domTree .t8 code { color: green; }
158: ul.domTree .t10 code { color: teal; }
159:
160: body.dfnEnabled dfn { cursor: pointer; }
161: .dfnPanel {
162: display: inline;
163: position: absolute;
164: z-index: 10;
165: height: auto;
166: width: auto;
167: padding: 0.5em 0.75em;
168: font: small sans-serif, Droid Sans Fallback;
169: background: #DDDDDD;
170: color: black;
171: border: outset 0.2em;
172: }
173: .dfnPanel * { margin: 0; padding: 0; font: inherit; text-indent: 0; }
174: .dfnPanel :link, .dfnPanel :visited { color: black; }
175: .dfnPanel p { font-weight: bolder; }
176: .dfnPanel * + p { margin-top: 0.25em; }
177: .dfnPanel li { list-style-position: inside; }
178:
179: #configUI { position: absolute; z-index: 20; top: 10em; right: 1em; width: 11em; font-size: small; }
180: #configUI p { margin: 0.5em 0; padding: 0.3em; background: #EEEEEE; color: black; border: inset thin; }
181: #configUI p label { display: block; }
182: #configUI #updateUI, #configUI .loginUI { text-align: center; }
183: #configUI input[type=button] { display: block; margin: auto; }
184: </style><style type="text/css">
185:
186: .applies thead th > * { display: block; }
187: .applies thead code { display: block; }
188: .applies tbody th { whitespace: nowrap; }
189: .applies td { text-align: center; }
190: .applies .yes { background: yellow; }
191:
192: .matrix, .matrix td { border: none; text-align: right; }
193: .matrix { margin-left: 2em; }
194:
195: .dice-example { border-collapse: collapse; border-style: hidden solid solid hidden; border-width: thin; margin-left: 3em; }
196: .dice-example caption { width: 30em; font-size: smaller; font-style: italic; padding: 0.75em 0; text-align: left; }
197: .dice-example td, .dice-example th { border: solid thin; width: 1.35em; height: 1.05em; text-align: center; padding: 0; }
198:
199: #table-example-1 { border: solid thin; border-collapse: collapse; margin-left: 3em; }
200: #table-example-1 * { font-family: "Essays1743", serif; line-height: 1.01em; }
201: #table-example-1 caption { padding-bottom: 0.5em; }
202: #table-example-1 thead, #table-example-1 tbody { border: none; }
203: #table-example-1 th, #table-example-1 td { border: solid thin; }
204: #table-example-1 th { font-weight: normal; }
205: #table-example-1 td { border-style: none solid; vertical-align: top; }
206: #table-example-1 th { padding: 0.5em; vertical-align: middle; text-align: center; }
207: #table-example-1 tbody tr:first-child td { padding-top: 0.5em; }
208: #table-example-1 tbody tr:last-child td { padding-bottom: 1.5em; }
209: #table-example-1 tbody td:first-child { padding-left: 2.5em; padding-right: 0; width: 9em; }
210: #table-example-1 tbody td:first-child::after { content: leader(". "); }
211: #table-example-1 tbody td { padding-left: 2em; padding-right: 2em; }
212: #table-example-1 tbody td:first-child + td { width: 10em; }
213: #table-example-1 tbody td:first-child + td ~ td { width: 2.5em; }
214: #table-example-1 tbody td:first-child + td + td + td ~ td { width: 1.25em; }
215:
216: .apple-table-examples { border: none; border-collapse: separate; border-spacing: 1.5em 0em; width: 40em; margin-left: 3em; }
217: .apple-table-examples * { font-family: "Times", serif; }
218: .apple-table-examples td, .apple-table-examples th { border: none; white-space: nowrap; padding-top: 0; padding-bottom: 0; }
219: .apple-table-examples tbody th:first-child { border-left: none; width: 100%; }
220: .apple-table-examples thead th:first-child ~ th { font-size: smaller; font-weight: bolder; border-bottom: solid 2px; text-align: center; }
221: .apple-table-examples tbody th::after, .apple-table-examples tfoot th::after { content: leader(". ") }
222: .apple-table-examples tbody th, .apple-table-examples tfoot th { font: inherit; text-align: left; }
223: .apple-table-examples td { text-align: right; vertical-align: top; }
224: .apple-table-examples.e1 tbody tr:last-child td { border-bottom: solid 1px; }
225: .apple-table-examples.e1 tbody + tbody tr:last-child td { border-bottom: double 3px; }
226: .apple-table-examples.e2 th[scope=row] { padding-left: 1em; }
227: .apple-table-examples sup { line-height: 0; }
228:
229: .details-example img { vertical-align: top; }
230:
231: #named-character-references-table {
232: font-size: 0.6em;
233: column-width: 28em;
234: column-gap: 1em;
235: -moz-column-width: 28em;
236: -moz-column-gap: 1em;
237: -webkit-column-width: 28em;
238: -webkit-column-gap: 1em;
239: }
240: #named-character-references-table > table > tbody > tr > td:last-child { text-align: center; }
241: #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; }
242:
1.2 mike 243: .glyph.control { color: red; }
244:
1.4 mike 245: @font-face {
246: font-family: 'Essays1743';
247: src: url('http://www.whatwg.org/specs/web-apps/current-work/fonts/Essays1743.ttf');
248: }
249: @font-face {
250: font-family: 'Essays1743';
251: font-weight: bold;
252: src: url('http://www.whatwg.org/specs/web-apps/current-work/fonts/Essays1743-Bold.ttf');
253: }
254: @font-face {
255: font-family: 'Essays1743';
256: font-style: italic;
257: src: url('http://www.whatwg.org/specs/web-apps/current-work/fonts/Essays1743-Italic.ttf');
258: }
259: @font-face {
260: font-family: 'Essays1743';
261: font-style: italic;
262: font-weight: bold;
263: src: url('http://www.whatwg.org/specs/web-apps/current-work/fonts/Essays1743-BoldItalic.ttf');
264: }
265:
1.1 mike 266: </style><style type="text/css">
267: .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; }
268: </style><link href="data:text/css," id="complete" rel="stylesheet" title="Complete specification"><link href="data:text/css,.impl%20%7B%20display:%20none;%20%7D%0Ahtml%20%7B%20border:%20solid%20yellow;%20%7D%20.domintro:before%20%7B%20display:%20none;%20%7D" id="author" rel="alternate stylesheet" title="Author documentation only"><link href="data:text/css,.impl%20%7B%20background:%20%23FFEEEE;%20%7D%20.domintro:before%20%7B%20background:%20%23FFEEEE;%20%7D" id="highlight" rel="alternate stylesheet" title="Highlight implementation requirements"><script type="text/javascript">
269: function getCookie(name) {
270: var params = location.search.substr(1).split("&");
271: for (var index = 0; index < params.length; index++) {
272: if (params[index] == name)
273: return "1";
274: var data = params[index].split("=");
275: if (data[0] == name)
276: return unescape(data[1]);
277: }
278: var cookies = document.cookie.split("; ");
279: for (var index = 0; index < cookies.length; index++) {
280: var data = cookies[index].split("=");
281: if (data[0] == name)
282: return unescape(data[1]);
283: }
284: return null;
285: }
286: function load(script) {
287: var e = document.createElement('script');
288: e.setAttribute('src', 'http://www.whatwg.org/specs/web-apps/current-work/' + script + '?' + encodeURIComponent(location) + '&' + encodeURIComponent(document.referrer));
289: document.body.appendChild(e);
290: }
291: function init() {
292: if (location.search == '?slow-browser')
293: return;
294: var configUI = document.createElement('div');
295: configUI.id = 'configUI';
296: document.body.appendChild(configUI);
297: // load('reviewer.js'); // would need cross-site XHR
298: if (document.getElementById('head'))
299: load('toc.js');
300: load('styler.js');
301: // load('updater.js'); // would need cross-site XHR
302: load('dfn.js'); // doesn't support split-out specs, but, oh well.
303: // load('status.js'); // would need cross-site XHR
304: if (getCookie('profile') == '1')
305: document.getElementsByTagName('h2')[0].textContent += '; load: ' + (new Date() - loadTimer) + 'ms';
306: fixBrokenLink();
307: }
1.6 mike 308: </script><link href="http://www.w3.org/StyleSheets/TR/W3C-ED" rel="stylesheet" type="text/css">
1.1 mike 309: <script src="link-fixup.js"></script>
310: <link href="number-state.html" title="4.10.7.1.13 Number state" rel="prev">
311: <link href="spec.html#contents" title="Table of contents" rel="index">
312: <link href="the-button-element.html" title="4.10.8 The button element" rel="next">
313: </head><body onload="fixBrokenLink(); init()"><div class="head" id="head">
314: <p><a href="http://www.w3.org/"><img alt="W3C" height="48" src="http://www.w3.org/Icons/w3c_home" width="72"></a></p>
1.3 mike 315:
1.1 mike 316: <h1>HTML5</h1>
317: </div><div>
318: <a href="number-state.html">← 4.10.7.1.13 Number state</a> –
319: <a href="spec.html#contents">Table of contents</a> –
320: <a href="the-button-element.html">4.10.8 The button element →</a>
321: <ol class="toc"><li><ol><li><ol><li><ol><li><a href="common-input-element-attributes.html#common-input-element-attributes"><span class="secno">4.10.7.2 </span>Common <code>input</code> element attributes</a>
322: <ol><li><a href="common-input-element-attributes.html#the-autocomplete-attribute"><span class="secno">4.10.7.2.1 </span>The <code title="attr-input-autocomplete">autocomplete</code> attribute</a></li><li><a href="common-input-element-attributes.html#the-list-attribute"><span class="secno">4.10.7.2.2 </span>The <code title="attr-input-list">list</code> attribute</a></li><li><a href="common-input-element-attributes.html#the-readonly-attribute"><span class="secno">4.10.7.2.3 </span>The <code title="attr-input-readonly">readonly</code> attribute</a></li><li><a href="common-input-element-attributes.html#the-size-attribute"><span class="secno">4.10.7.2.4 </span>The <code title="attr-input-size">size</code> attribute</a></li><li><a href="common-input-element-attributes.html#the-required-attribute"><span class="secno">4.10.7.2.5 </span>The <code title="attr-input-required">required</code> attribute</a></li><li><a href="common-input-element-attributes.html#the-multiple-attribute"><span class="secno">4.10.7.2.6 </span>The <code title="attr-input-multiple">multiple</code> attribute</a></li><li><a href="common-input-element-attributes.html#the-maxlength-attribute"><span class="secno">4.10.7.2.7 </span>The <code title="attr-input-maxlength">maxlength</code> attribute</a></li><li><a href="common-input-element-attributes.html#the-pattern-attribute"><span class="secno">4.10.7.2.8 </span>The <code title="attr-input-pattern">pattern</code> attribute</a></li><li><a href="common-input-element-attributes.html#the-min-and-max-attributes"><span class="secno">4.10.7.2.9 </span>The <code title="attr-input-min">min</code> and <code title="attr-input-max">max</code> attributes</a></li><li><a href="common-input-element-attributes.html#the-step-attribute"><span class="secno">4.10.7.2.10 </span>The <code title="attr-input-step">step</code> attribute</a></li><li><a href="common-input-element-attributes.html#the-placeholder-attribute"><span class="secno">4.10.7.2.11 </span>The <code title="attr-input-placeholder">placeholder</code> attribute</a></li></ol></li><li><a href="common-input-element-attributes.html#common-input-element-apis"><span class="secno">4.10.7.3 </span>Common <code>input</code> element APIs</a></li><li><a href="common-input-element-attributes.html#common-event-behaviors"><span class="secno">4.10.7.4 </span>Common event behaviors</a></li></ol></li></ol></li></ol></li></ol></div>
323:
324: <h5 id="common-input-element-attributes"><span class="secno">4.10.7.2 </span>Common <code><a href="the-input-element.html#the-input-element">input</a></code> element attributes</h5><p class="XXX annotation"><b>Status: </b><i>Last call for comments</i></p><div class="impl">
325:
326: <p>These attributes only apply to an <code><a href="the-input-element.html#the-input-element">input</a></code> element if
327: its <code title="attr-input-type"><a href="the-input-element.html#attr-input-type">type</a></code> attribute is in a
328: state whose definition declares that the attribute applies. When an
329: attribute doesn't apply to an <code><a href="the-input-element.html#the-input-element">input</a></code> element, user
330: agents must <a href="infrastructure.html#ignore">ignore</a> the attribute, regardless of the
331: requirements and definitions below.</p>
332:
333: </div><h6 id="the-autocomplete-attribute"><span class="secno">4.10.7.2.1 </span>The <code title="attr-input-autocomplete"><a href="#attr-input-autocomplete">autocomplete</a></code> attribute</h6><p class="XXX annotation"><b>Status: </b><i>Last call for comments</i></p><p>User agents sometimes have features for helping users fill forms
334: in, for example prefilling the user's address based on earlier user
335: input.</p><p>The <dfn id="attr-input-autocomplete" title="attr-input-autocomplete"><code>autocomplete</code></dfn>
336: attribute is an <a href="common-microsyntaxes.html#enumerated-attribute">enumerated attribute</a>. The attribute has
337: three states. The <code title="attr-input-autocomplete-on">on</code>
338: keyword maps to the <dfn id="attr-input-autocomplete-on-state" title="attr-input-autocomplete-on-state">on</dfn> state, and the
339: <code title="attr-input-autocomplete-off">off</code> keyword maps to
340: the <dfn id="attr-input-autocomplete-off-state" title="attr-input-autocomplete-off-state">off</dfn>
341: state. The attribute may also be omitted. The <i>missing value
342: default</i> is the <dfn id="attr-input-autocomplete-default-state" title="attr-input-autocomplete-default-state">default</dfn>
343: state.</p><p>The <a href="#attr-input-autocomplete-off-state" title="attr-input-autocomplete-off-state">off</a>
344: state indicates either that the control's input data is particularly
345: sensitive (for example the activation code for a nuclear weapon); or
346: that it is a value that will never be reused (for example a
347: one-time-key for a bank login) and the user will therefore have to
348: explicitly enter the data each time, instead of being able to rely
349: on the UA to prefill the value for him; or that the document
350: provides its own autocomplete mechanism and does not want the user
351: agent to provide autocompletion values.</p><p>Conversely, the <a href="#attr-input-autocomplete-on-state" title="attr-input-autocomplete-on-state">on</a> state indicates
352: that the value is not particularly sensitive and the user can expect
353: to be able to rely on his user agent to remember values he has
354: entered for that control.</p><p>The <a href="#attr-input-autocomplete-default-state" title="attr-input-autocomplete-default-state">default</a> state
355: indicates that the user agent is to use the <code title="attr-form-autocomplete"><a href="forms.html#attr-form-autocomplete">autocomplete</a></code> attribute on the
356: element's <a href="association-of-controls-and-forms.html#form-owner">form owner</a> instead. (By default, the <code title="attr-form-autocomplete"><a href="forms.html#attr-form-autocomplete">autocomplete</a></code> attribute of
357: <code><a href="forms.html#the-form-element">form</a></code> elements is in the <a href="forms.html#attr-form-autocomplete-on-state" title="attr-form-autocomplete-on-state">on</a> state.)</p><div class="impl">
358:
359: <p>Each <code><a href="the-input-element.html#the-input-element">input</a></code> element has a <dfn id="resulting-autocompletion-state">resulting
360: autocompletion state</dfn>, which is either <i title="">on</i> or <i title="">off</i>.</p>
361:
362: <p>When an <code><a href="the-input-element.html#the-input-element">input</a></code> element is in one of the following
363: conditions, the <code><a href="the-input-element.html#the-input-element">input</a></code> element's <a href="#resulting-autocompletion-state">resulting
364: autocompletion state</a> is <i title="">on</i>; otherwise, the
365: <code><a href="the-input-element.html#the-input-element">input</a></code> element's <a href="#resulting-autocompletion-state">resulting autocompletion
366: state</a> is <i title="">off</i>:</p>
367:
368: <ul class="brief"><li>Its <code title="attr-input-autocomplete"><a href="#attr-input-autocomplete">autocomplete</a></code>
369: attribute is in the <a href="#attr-input-autocomplete-on-state" title="attr-input-autocomplete-on-state">on</a> state.</li>
370:
371: <li>Its <code title="attr-input-autocomplete"><a href="#attr-input-autocomplete">autocomplete</a></code>
372: attribute is in the <a href="#attr-input-autocomplete-default-state" title="attr-input-autocomplete-default-state">default</a> state,
373: and the element has no <a href="association-of-controls-and-forms.html#form-owner">form owner</a>.</li>
374:
375: <li>Its <code title="attr-input-autocomplete"><a href="#attr-input-autocomplete">autocomplete</a></code>
376: attribute is in the <a href="#attr-input-autocomplete-default-state" title="attr-input-autocomplete-default-state">default</a> state,
377: and the element's <a href="association-of-controls-and-forms.html#form-owner">form owner</a>'s <code title="attr-form-autocomplete"><a href="forms.html#attr-form-autocomplete">autocomplete</a></code> attribute is in
378: the <a href="forms.html#attr-form-autocomplete-on-state" title="attr-form-autocomplete-on-state">on</a>
379: state.</li>
380:
381: </ul><p>When an <code><a href="the-input-element.html#the-input-element">input</a></code> element's <a href="#resulting-autocompletion-state">resulting
382: autocompletion state</a> is <i title="">on</i>, the user agent
383: may store the value entered by the user so that if the user returns
384: to the page, the UA can prefill the form. Otherwise, the user agent
385: should not remember the control's <a href="association-of-controls-and-forms.html#concept-fe-value" title="concept-fe-value">value</a>, and should not offer past
386: values to the user.</p>
387:
388: <p>In addition, if the <a href="#resulting-autocompletion-state">resulting autocompletion state</a>
389: is <i title="">off</i>, <a href="history.html#history-autocomplete">values are
390: reset</a> when <a href="history.html#traverse-the-history" title="traverse the history">traversing the
391: history</a>.</p>
392:
393: <p>The autocompletion mechanism must be implemented by the user
394: agent acting as if the user had modified the element's <a href="association-of-controls-and-forms.html#concept-fe-value" title="concept-fe-value">value</a>, and must be done at a time
395: where the element is <i title="concept-input-mutable"><a href="the-input-element.html#concept-input-mutable">mutable</a></i>
396: (e.g. just after the element has been inserted into the document, or
397: when the user agent <a href="the-end.html#stop-parsing" title="stop parsing">stops
398: parsing</a>).</p>
399:
400: </div><div class="example">
401:
402: <p>Banks frequently do not want UAs to prefill login
403: information:</p>
404:
405: <pre><p><label>Account: <input type="text" name="ac" autocomplete="off"></label></p>
406: <p><label>PIN: <input type="password" name="pin" autocomplete="off"></label></p></pre>
407:
408: </div><div class="impl">
409:
410: <p>A user agent may allow the user to override the <a href="#resulting-autocompletion-state">resulting
411: autocompletion state</a> and set it to always <i title="">on</i>,
412: always allowing values to be remembered and prefilled), or always <i title="">off</i>, never remembering values. However, the ability to
413: override the <a href="#resulting-autocompletion-state">resulting autocompletion state</a> to <i title="">on</i> should not be trivially accessible, as there are
414: significant security implications for the user if all values are
415: always remembered, regardless of the site's preferences.</p>
416:
417: </div><h6 id="the-list-attribute"><span class="secno">4.10.7.2.2 </span>The <code title="attr-input-list"><a href="#attr-input-list">list</a></code> attribute</h6><p class="XXX annotation"><b>Status: </b><i>Last call for comments</i></p><p>The <dfn id="attr-input-list" title="attr-input-list"><code>list</code></dfn>
418: attribute is used to identify an element that lists predefined
419: options suggested to the user.</p><p>If present, its value must be the ID of a <code><a href="the-button-element.html#the-datalist-element">datalist</a></code>
420: element in the same document.</p><div class="impl">
421:
422: <p>The <dfn id="concept-input-list" title="concept-input-list">suggestions source
423: element</dfn> is the first element in the document in <a href="infrastructure.html#tree-order">tree
424: order</a> to have an ID equal to the value of the <code title="attr-input-list"><a href="#attr-input-list">list</a></code> attribute, if that element is a
425: <code><a href="the-button-element.html#the-datalist-element">datalist</a></code> element. If there is no <code title="attr-input-list"><a href="#attr-input-list">list</a></code> attribute, or if there is no
426: element with that ID, or if the first element with that ID is not a
427: <code><a href="the-button-element.html#the-datalist-element">datalist</a></code> element, then there is no <a href="#concept-input-list" title="concept-input-list">suggestions source element</a>.</p>
428:
429: <p>If there is a <a href="#concept-input-list" title="concept-input-list">suggestions source
430: element</a>, then, when the user agent is allowing the user to
431: edit the <code><a href="the-input-element.html#the-input-element">input</a></code> element's <a href="association-of-controls-and-forms.html#concept-fe-value" title="concept-fe-value">value</a>, the user agent should offer
432: the suggestions represented by the <a href="#concept-input-list" title="concept-input-list">suggestions source element</a> to the
433: user in a manner suitable for the type of control used. The user
434: agent may use the suggestion's <a href="the-button-element.html#concept-option-label" title="concept-option-label">label</a> to identify the suggestion
435: if appropriate. If the user selects a suggestion, then the
436: <code><a href="the-input-element.html#the-input-element">input</a></code> element's <a href="association-of-controls-and-forms.html#concept-fe-value" title="concept-fe-value">value</a> must be set to the selected
437: suggestion's <a href="the-button-element.html#concept-option-value" title="concept-option-value">value</a>, as if
438: the user had written that value himself.</p>
439:
440: <p>User agents must filter the suggestions to hide suggestions that
441: the user would not be allowed to enter as the <code><a href="the-input-element.html#the-input-element">input</a></code>
442: element's <a href="association-of-controls-and-forms.html#concept-fe-value" title="concept-fe-value">value</a>, and should
443: filter the suggestions to hide suggestions that would cause the
444: element to not <a href="association-of-controls-and-forms.html#concept-fv-valid" title="concept-fv-valid">satisfy its
445: constraints</a>.</p>
446:
447: <hr><p>If the <code title="attr-input-list"><a href="#attr-input-list">list</a></code> attribute does
448: not apply, there is no <a href="#concept-input-list" title="concept-input-list">suggestions
449: source element</a>.</p>
450:
451: </div><div class="example">
452:
453: <p>This URL field offers some suggestions.</p>
454:
455: <pre><label>Homepage: <input name=hp type=url list=hpurls></label>
456: <datalist id=hpurls>
457: <option value="http://www.google.com/" label="Google">
458: <option value="http://www.reddit.com/" label="Reddit">
459: </datalist></pre>
460:
461: <p>Other URLs from the user's history might show also; this is up
462: to the user agent.</p>
463:
464: </div><div class="example">
465:
466: <p>This example demonstrates how to design a form that uses the
467: autocompletion list feature while still degrading usefully in
468: legacy user agents.</p>
469:
470: <p>If the autocompletion list is merely an aid, and is not
471: important to the content, then simply using a <code><a href="the-button-element.html#the-datalist-element">datalist</a></code>
472: element with children <code><a href="the-button-element.html#the-option-element">option</a></code> elements is enough. To
473: prevent the values from being rendered in legacy user agents, they
474: should be placed inside the <code title="attr-option-value"><a href="the-button-element.html#attr-option-value">value</a></code> attribute instead of
475: inline.</p>
476:
477: <pre><p>
478: <label>
479: Enter a breed:
480: <input type="text" name="breed" list="breeds">
481: <datalist id="breeds">
482: <option value="Abyssinian">
483: <option value="Alpaca">
484: <!-- ... -->
485: </datalist>
486: </label>
487: </p></pre>
488:
489: <p>However, if the values need to be shown in legacy UAs, then
490: fallback content can be placed inside the <code><a href="the-button-element.html#the-datalist-element">datalist</a></code>
491: element, as follows:</p>
492:
493: <pre><p>
494: <label>
495: Enter a breed:
496: <input type="text" name="breed" list="breeds">
497: </label>
498: <datalist id="breeds">
499: <label>
500: or select one from the list:
501: <select name="breed">
502: <option value=""> (none selected)
503: <option>Abyssinian
504: <option>Alpaca
505: <!-- ... -->
506: </select>
507: </label>
508: </datalist>
509: </p>
510: </pre>
511:
512: <p>The fallback content will only be shown in UAs that don't
513: support <code><a href="the-button-element.html#the-datalist-element">datalist</a></code>. The options, on the other hand, will
514: be detected by all UAs, even though they are not direct children of
515: the <code><a href="the-button-element.html#the-datalist-element">datalist</a></code> element.</p>
516:
517: <p>Note that if an <code><a href="the-button-element.html#the-option-element">option</a></code> element used in a
518: <code><a href="the-button-element.html#the-datalist-element">datalist</a></code> is <code title="attr-option-selected"><a href="the-button-element.html#attr-option-selected">selected</a></code>, it will be selected
519: by default by legacy UAs (because it affects the
520: <code><a href="the-button-element.html#the-select-element">select</a></code>), but it will not have any effect on the
521: <code><a href="the-input-element.html#the-input-element">input</a></code> element in UAs that support
522: <code><a href="the-button-element.html#the-datalist-element">datalist</a></code>.</p>
523:
524: </div><h6 id="the-readonly-attribute"><span class="secno">4.10.7.2.3 </span>The <code title="attr-input-readonly"><a href="#attr-input-readonly">readonly</a></code> attribute</h6><p class="XXX annotation"><b>Status: </b><i>Last call for comments</i></p><p>The <dfn id="attr-input-readonly" title="attr-input-readonly"><code>readonly</code></dfn>
525: attribute is a <a href="common-microsyntaxes.html#boolean-attribute">boolean attribute</a> that controls whether
526: or not the use can edit the form control. <span class="impl">When
527: specified, the element is <i title="concept-input-immutable"><a href="the-input-element.html#concept-input-immutable">immutable</a></i>.</span></p><div class="impl">
528:
529: <p><strong>Constraint validation</strong>: If the <code title="attr-input-readonly"><a href="#attr-input-readonly">readonly</a></code> attribute is specified
530: on an <code><a href="the-input-element.html#the-input-element">input</a></code> element, the element is <a href="association-of-controls-and-forms.html#barred-from-constraint-validation">barred from
531: constraint validation</a>.</p>
532:
533: </div><div class="example">
534:
535: <p>In the following example, the existing product identifiers
536: cannot be modified, but they are still displayed as part of the
537: form, for consistency with the row representing a new product
538: (where the identifier is not yet filled in).</p>
539:
540: <pre><form action="products.cgi" method=post enctype="multipart/form-data">
541: <table>
542: <tr> <th> Product ID <th> Product name <th> Price <th> Action
543: <tr>
544: <td> <input readonly name="1.pid" value="H412">
545: <td> <input required name="1.pname" value="Floor lamp Ulke">
546: <td> $<input required type=number min=0 step=0.01 name="1.pprice" value="49.99">
547: <td> <button formnovalidate name="action" value="delete:1">Delete</button>
548: <tr>
549: <td> <input readonly name="2.pid" value="FG28">
550: <td> <input required name="2.pname" value="Table lamp Ulke">
551: <td> $<input required type=number min=0 step=0.01 name="2.pprice" value="24.99">
552: <td> <button formnovalidate name="action" value="delete:2">Delete</button>
553: <tr>
554: <td> <input required name="3.pid" value="" pattern="[A-Z0-9]+">
555: <td> <input required name="3.pname" value="">
556: <td> $<input required type=number min=0 step=0.01 name="3.pprice" value="">
557: <td> <button formnovalidate name="action" value="delete:3">Delete</button>
558: </table>
559: <p> <button formnovalidate name="action" value="add">Add</button> </p>
560: <p> <button name="action" value="update">Save</button> </p>
561: </form></pre>
562:
563: </div><h6 id="the-size-attribute"><span class="secno">4.10.7.2.4 </span>The <code title="attr-input-size"><a href="#attr-input-size">size</a></code> attribute</h6><p class="XXX annotation"><b>Status: </b><i>Last call for comments</i></p><p>The <dfn id="attr-input-size" title="attr-input-size"><code>size</code></dfn>
564: attribute gives the number of characters that, in a visual
565: rendering, the user agent is to allow the user to see while editing
566: the element's <a href="association-of-controls-and-forms.html#concept-fe-value" title="concept-fe-value">value</a>.</p><p>The <code title="attr-input-size"><a href="#attr-input-size">size</a></code> attribute, if
567: specified, must have a value that is a <a href="common-microsyntaxes.html#valid-non-negative-integer">valid non-negative
568: integer</a> greater than zero.</p><div class="impl">
569:
570: <p>If the attribute is present, then its value must be parsed using
571: the <a href="common-microsyntaxes.html#rules-for-parsing-non-negative-integers">rules for parsing non-negative integers</a>, and if the
572: result is a number greater than zero, then the user agent should
573: ensure that at least that many characters are visible.</p>
574:
575: <p>The <code title="dom-input-size"><a href="the-input-element.html#dom-input-size">size</a></code> IDL attribute is
576: <a href="common-dom-interfaces.html#limited-to-only-non-negative-numbers-greater-than-zero">limited to only non-negative numbers greater than
577: zero</a>.</p>
578:
579: </div><h6 id="the-required-attribute"><span class="secno">4.10.7.2.5 </span>The <code title="attr-input-required"><a href="#attr-input-required">required</a></code> attribute</h6><p class="XXX annotation"><b>Status: </b><i>Last call for comments</i></p><p>The <dfn id="attr-input-required" title="attr-input-required"><code>required</code></dfn>
580: attribute is a <a href="common-microsyntaxes.html#boolean-attribute">boolean attribute</a>. When specified, the
581: element is <dfn id="concept-input-required" title="concept-input-required"><i>required</i></dfn>.</p><div class="impl">
582:
583: <p><strong>Constraint validation</strong>: If the element is <i title="concept-input-required"><a href="#concept-input-required">required</a></i>, and its <code title="dom-input-value"><a href="#dom-input-value">value</a></code> IDL attribute applies and is in
584: the mode <a href="#dom-input-value-value" title="dom-input-value-value">value</a>, and the
585: element is <i title="concept-input-mutable"><a href="the-input-element.html#concept-input-mutable">mutable</a></i>, and the
586: element's <a href="association-of-controls-and-forms.html#concept-fe-value" title="concept-fe-value">value</a> is the empty
587: string, then the element is <a href="association-of-controls-and-forms.html#suffering-from-being-missing">suffering from being
588: missing</a>.</p>
589:
590: </div><div class="example">
591:
592: <p>The following form has two required fields, one for an e-mail
593: address and one for a password. It also has a third field that is
594: only considerd valid if the user types the same password in the
595: password field and this third field.</p>
596:
597: <pre><h1>Create new account</h1>
598: <form action="/newaccount" method=post>
599: <p>
600: <label for="username">E-mail address:</label>
601: <input id="username" type=email required name=un>
602: <p>
603: <label for="password1">Password:</label>
604: <input id="password1" type=password required name=up>
605: <p>
606: <label for="password2">Confirm password:</label>
607: <input id="password2" type=password onforminput="setCustomValidity(value != password1.value ? 'Passwords do not match.' : '')">
608: <p>
609: <input type=submit value="Create account">
610: </form></pre>
611:
612: </div><h6 id="the-multiple-attribute"><span class="secno">4.10.7.2.6 </span>The <code title="attr-input-multiple"><a href="#attr-input-multiple">multiple</a></code> attribute</h6><p class="XXX annotation"><b>Status: </b><i>Last call for comments</i></p><p>The <dfn id="attr-input-multiple" title="attr-input-multiple"><code>multiple</code></dfn>
613: attribute is a <a href="common-microsyntaxes.html#boolean-attribute">boolean attribute</a> that indicates whether
614: the user is to be allowed to specify more than one value.</p><div class="example">
615:
616: <p>The following extract shows how an e-mail client's "Cc" field
617: could accept multiple e-mail addresses.</p>
618:
619: <pre><label>Cc: <input type=email multiple name=cc></label></pre>
620:
621: <p>If the user had, amongst many friends in his user contacts
622: database, two friends "Arthur Dent" (with address
623: "art@example.net") and "Adam Josh" (with address
624: "adamjosh@example.net"), then, after the user has typed "a", the
625: user agent might suggest these two e-mail addresses to the
626: user.</p>
627:
628: <p><img alt="" src="http://dev.w3.org/html5/spec/images/sample-email-1.png"></p>
629:
630: <p>The page could also link in the user's contacts database from the site:</p>
631:
632: <pre><label>Cc: <input type=email multiple name=cc list=contacts></label>
633: ...
634: <datalist id="contacts">
635: <option value="hedral@damowmow.com">
636: <option value="pillar@example.com">
637: <option value="astrophy@cute.example">
638: <option value="astronomy@science.example.org">
639: </datalist></pre>
640:
641: <p>Suppose the user had entered "bob@example.net" into this text
642: field, and then started typing a second e-mail address starting
643: with "a". The user agent might show both the two friends mentioned
644: earlier, as well as the "astrophy" and "astronomy" values given in
645: the <code><a href="the-button-element.html#the-datalist-element">datalist</a></code> element.</p>
646:
647: <p><img alt="" src="http://dev.w3.org/html5/spec/images/sample-email-2.png"></p>
648:
649: </div><div class="example">
650:
651: <p>The following extract shows how an e-mail client's "Attachments"
652: field could accept multiple files for upload.</p>
653:
654: <pre><label>Attachments: <input type=file multiple name=att></label></pre>
655:
656: </div><h6 id="the-maxlength-attribute"><span class="secno">4.10.7.2.7 </span>The <code title="attr-input-maxlength"><a href="#attr-input-maxlength">maxlength</a></code> attribute</h6><p class="XXX annotation"><b>Status: </b><i>Last call for comments</i></p><p>The <dfn id="attr-input-maxlength" title="attr-input-maxlength"><code>maxlength</code></dfn>
657: attribute<span class="impl">, when it applies,</span> is a <a href="association-of-controls-and-forms.html#attr-fe-maxlength" title="attr-fe-maxlength">form control <code title="">maxlength</code> attribute</a><span class="impl">
658: controlled by the <code><a href="the-input-element.html#the-input-element">input</a></code> element's <a href="the-input-element.html#concept-input-value-dirty-flag" title="concept-input-value-dirty-flag">dirty value
659: flag</a></span>.</p><p>If the <code><a href="the-input-element.html#the-input-element">input</a></code> element has a <a href="association-of-controls-and-forms.html#maximum-allowed-value-length">maximum allowed
660: value length</a>, then the <a href="common-microsyntaxes.html#code-point-length">code-point length</a> of the
661: value of the element's <code title="attr-input-value"><a href="the-input-element.html#attr-input-value">value</a></code>
662: attribute must be equal to or less than the element's <a href="association-of-controls-and-forms.html#maximum-allowed-value-length">maximum
663: allowed value length</a>.</p><div class="example">
664:
665: <p>The following extract shows how a messaging client's text entry
666: could be arbitrarily restricted to a fixed number of characters,
667: thus forcing any conversion through this medium to be terse and
668: discouraging intelligent discourse.</p>
669:
670: <pre>What are you doing? <input name=status maxlength=140></pre>
671:
672: </div><h6 id="the-pattern-attribute"><span class="secno">4.10.7.2.8 </span>The <code title="attr-input-pattern"><a href="#attr-input-pattern">pattern</a></code> attribute</h6><p class="XXX annotation"><b>Status: </b><i>Last call for comments</i></p><p>The <dfn id="attr-input-pattern" title="attr-input-pattern"><code>pattern</code></dfn>
673: attribute specifies a regular expression against which the control's
674: <a href="association-of-controls-and-forms.html#concept-fe-value" title="concept-fe-value">value</a> is to be checked.</p><p>If specified, the attribute's value must match the JavaScript <i title="">Pattern</i> production. <a href="references.html#refsECMA262">[ECMA262]</a></p><div class="impl">
675:
676: <p><strong>Constraint validation</strong>: If the element's <a href="association-of-controls-and-forms.html#concept-fe-value" title="concept-fe-value">value</a> is not the empty string, and
677: the element's <code title="attr-input-pattern"><a href="#attr-input-pattern">pattern</a></code>
678: attribute is specified and the attribute's value, when compiled as a
679: JavaScript regular expression with the <code title="">global</code>,
680: <code title="">ignoreCase</code>, and <code title="">multiline</code> flags <em>disabled</em> (see ECMA262
681: Edition 5, sections 15.10.7.2 through 15.10.7.4), compiles
682: successfully but the resulting regular expression does not match the
683: entirety of the element's <a href="association-of-controls-and-forms.html#concept-fe-value" title="concept-fe-value">value</a>, then the element is
684: <a href="association-of-controls-and-forms.html#suffering-from-a-pattern-mismatch">suffering from a pattern mismatch</a>. <a href="references.html#refsECMA262">[ECMA262]</a></p>
685:
686: <p class="note">This implies that the regular expression language
687: used for this attribute is the same as that used in JavaScript,
688: except that the <code title="attr-input-pattern"><a href="#attr-input-pattern">pattern</a></code>
689: attribute must match the entire value, not just any subset (somewhat
690: as if it implied a <code title="">^(?:</code> at the start of the
691: pattern and a <code title="">)$</code> at the end).</p>
692:
693: </div><p>When an <code><a href="the-input-element.html#the-input-element">input</a></code> element has a <code title="attr-input-pattern"><a href="#attr-input-pattern">pattern</a></code> attribute specified,
694: authors should include a <code title="attr-title"><a href="elements.html#the-title-attribute">title</a></code>
695: attribute to give a description of the pattern. User agents may use
696: the contents of this attribute, if it is present, when informing the
697: user that the pattern is not matched, or at any other suitable time,
698: such as in a tooltip or read out by assistive technology when the
699: control gains focus.</p><div class="example">
700: <p>For example, the following snippet:</p>
701: <pre><label> Part number:
702: <input pattern="[0-9][A-Z]{3}" name="part"
703: title="A part number is a digit followed by three uppercase letters."/>
704: </label></pre>
705: <p>...could cause the UA to display an alert such as:</p>
706: <pre><samp>A part number is a digit followed by three uppercase letters.
707: You cannot complete this form until the field is correct.</samp></pre>
708: </div><p>When a control has a <code title="attr-input-pattern"><a href="#attr-input-pattern">pattern</a></code> attribute, the <code title="attr-title"><a href="elements.html#the-title-attribute">title</a></code> attribute, if used, must describe
709: the pattern. Additional information could also be included, so long
710: as it assists the user in filling in the control. Otherwise,
711: assistive technology would be impaired.</p><p class="example">For instance, if the title attribute contained
712: the caption of the control, assistive technology could end up saying
713: something like <samp>The text you have entered does not match the
714: required pattern. Birthday</samp>, which is not useful.</p><p>UAs may still show the <code><a href="semantics.html#the-title-element-0">title</a></code> in non-error situations
715: (for example, as a tooltip when hovering over the control), so
716: authors should be careful not to word <code><a href="semantics.html#the-title-element-0">title</a></code>s as if an
717: error has necessarily occurred.</p><h6 id="the-min-and-max-attributes"><span class="secno">4.10.7.2.9 </span>The <code title="attr-input-min"><a href="#attr-input-min">min</a></code> and <code title="attr-input-max"><a href="#attr-input-max">max</a></code> attributes</h6><p class="XXX annotation"><b>Status: </b><i>Last call for comments</i></p><p>The <dfn id="attr-input-min" title="attr-input-min"><code>min</code></dfn> and <dfn id="attr-input-max" title="attr-input-max"><code>max</code></dfn> attributes indicate
718: the allowed range of values for the element.</p><div class="impl">
719:
720: <p>Their syntax is defined by the section that defines the <code title="attr-input-type"><a href="the-input-element.html#attr-input-type">type</a></code> attribute's current state.</p>
721:
722: <p>If the element has a <code title="attr-input-min"><a href="#attr-input-min">min</a></code>
723: attribute, and the result of applying the <a href="the-input-element.html#concept-input-value-string-number" title="concept-input-value-string-number">algorithm to convert a
724: string to a number</a> to the value of the <code title="attr-input-min"><a href="#attr-input-min">min</a></code> attribute is a number, then that
725: number is the element's <dfn id="concept-input-min" title="concept-input-min">minimum</dfn>; otherwise, if the <code title="attr-input-type"><a href="the-input-element.html#attr-input-type">type</a></code> attribute's current state
726: defines a <dfn id="concept-input-min-default" title="concept-input-min-default">default
727: minimum</dfn>, then that is the <a href="#concept-input-min" title="concept-input-min">minimum</a>; otherwise, the element has
728: no <a href="#concept-input-min" title="concept-input-min">minimum</a>.</p>
729:
730: <p><strong>Constraint validation</strong>: When the element has a
731: <a href="#attr-input-min" title="attr-input-min">minimum</a>, and the result of
732: applying the <a href="the-input-element.html#concept-input-value-string-number" title="concept-input-value-string-number">algorithm to convert a
733: string to a number</a> to the string given by the element's <a href="association-of-controls-and-forms.html#concept-fe-value" title="concept-fe-value">value</a> is a number, and the number
734: obtained from that algorithm is less than the <a href="#attr-input-min" title="attr-input-min">minimum</a>, the element is
735: <a href="association-of-controls-and-forms.html#suffering-from-an-underflow">suffering from an underflow</a>.</p>
736:
737: <p>The <code title="attr-input-min"><a href="#attr-input-min">min</a></code> attribute also
738: defines the <a href="#concept-input-min-zero" title="concept-input-min-zero">step
739: base</a>.</p>
740:
741: <p>If the element has a <code title="attr-input-max"><a href="#attr-input-max">max</a></code>
742: attribute, and the result of applying the <a href="the-input-element.html#concept-input-value-string-number" title="concept-input-value-string-number">algorithm to convert a
743: string to a number</a> to the value of the <code title="attr-input-max"><a href="#attr-input-max">max</a></code> attribute is a number, then that
744: number is the element's <dfn id="concept-input-max" title="concept-input-max">maximum</dfn>; otherwise, if the <code title="attr-input-type"><a href="the-input-element.html#attr-input-type">type</a></code> attribute's current state
745: defines a <dfn id="concept-input-max-default" title="concept-input-max-default">default
746: maximum</dfn>, then that is the <a href="#concept-input-max" title="concept-input-max">maximum</a>; otherwise, the element has
747: no <a href="#concept-input-max" title="concept-input-max">maximum</a>.</p>
748:
749: <p><strong>Constraint validation</strong>: When the element has a
750: <a href="#attr-input-max" title="attr-input-max">maximum</a>, and the result of
751: applying the <a href="the-input-element.html#concept-input-value-string-number" title="concept-input-value-string-number">algorithm to convert a
752: string to a number</a> to the string given by the element's <a href="association-of-controls-and-forms.html#concept-fe-value" title="concept-fe-value">value</a> is a number, and the number
753: obtained from that algorithm is more than the <a href="#attr-input-max" title="attr-input-max">maximum</a>, the element is
754: <a href="association-of-controls-and-forms.html#suffering-from-an-overflow">suffering from an overflow</a>.</p>
755:
756: </div><p>The <code title="attr-input-max"><a href="#attr-input-max">max</a></code> attribute's value
757: (the <a href="#concept-input-max" title="concept-input-max">maximum</a>) must not be
758: less than the <code title="attr-input-min"><a href="#attr-input-min">min</a></code> attribute's
759: value (its <a href="#concept-input-min" title="concept-input-min">minimum</a>).</p><div class="impl">
760:
761: <p class="note">If an element has a <a href="#attr-input-max" title="attr-input-max">maximum</a> that is less than its <a href="#attr-input-min" title="attr-input-min">minimum</a>, then so long as the element
762: has a <a href="association-of-controls-and-forms.html#concept-fe-value" title="concept-fe-value">value</a>, it will either be
763: <a href="association-of-controls-and-forms.html#suffering-from-an-underflow">suffering from an underflow</a> or <a href="association-of-controls-and-forms.html#suffering-from-an-overflow">suffering from an
764: overflow</a>.</p>
765:
766: </div><div class="example">
767:
768: <p>The following date control limits input to dates that are before
769: the 1980s:</p>
770:
771: <pre><input name=bday type=date max="1979-12-31"></pre>
772:
773: </div><div class="example">
774:
775: <p>The following number control limits input to whole numbers
776: greater than zero:</p>
777:
778: <pre><input name=quantity required type=number min=1 value=1></pre>
779:
780: </div><h6 id="the-step-attribute"><span class="secno">4.10.7.2.10 </span>The <code title="attr-input-step"><a href="#attr-input-step">step</a></code> attribute</h6><p class="XXX annotation"><b>Status: </b><i>Last call for comments</i></p><p>The <dfn id="attr-input-step" title="attr-input-step"><code>step</code></dfn>
781: attribute indicates the granularity that is expected (and required)
782: of the <a href="association-of-controls-and-forms.html#concept-fe-value" title="concept-fe-value">value</a>, by limiting the
783: allowed values. <span class="impl">The section that defines the
784: <code title="attr-input-type"><a href="the-input-element.html#attr-input-type">type</a></code> attribute's current state
785: also defines the <dfn id="concept-input-step-default" title="concept-input-step-default">default
786: step</dfn>, the <dfn id="concept-input-step-scale" title="concept-input-step-scale">step scale
787: factor</dfn>, and in some cases the <dfn id="concept-input-step-default-base" title="concept-input-step-default-base">default step base</dfn>,
788: which are used in processing the attribute as described
789: below.</span></p><p>The <code title="attr-input-step"><a href="#attr-input-step">step</a></code> attribute, if
790: specified, must either have a value that is a <a href="common-microsyntaxes.html#valid-floating-point-number">valid floating
791: point number</a> that <a href="common-microsyntaxes.html#rules-for-parsing-floating-point-number-values" title="rules for parsing floating
792: point number values">parses</a> to a number that is greater than
793: zero, or must have a value that is an <a href="infrastructure.html#ascii-case-insensitive">ASCII
794: case-insensitive</a> match for the string "<code title="">any</code>".</p><div class="impl">
795:
796: <p>The attribute provides the <dfn id="concept-input-step" title="concept-input-step">allowed value step</dfn> for the element,
797: as follows:</p>
798:
799: <ol><li>If the attribute is absent, then the <a href="#concept-input-step" title="concept-input-step">allowed value step</a> is the <a href="#concept-input-step-default" title="concept-input-step-default">default step</a> multiplied
800: by the <a href="#concept-input-step-scale" title="concept-input-step-scale">step scale
801: factor</a>.</li>
802:
803: <li>Otherwise, if the attribute's value is an <a href="infrastructure.html#ascii-case-insensitive">ASCII
804: case-insensitive</a> match for the string "<code title="">any</code>", then there is no <a href="#concept-input-step" title="concept-input-step">allowed value step</a>.</li>
805:
806: <li>Otherwise, if the <a href="common-microsyntaxes.html#rules-for-parsing-floating-point-number-values">rules for parsing floating point number
807: values</a>, when they are applied to the attribute's value,
808: return an error, zero, or a number less than zero, then the <a href="#concept-input-step" title="concept-input-step">allowed value step</a> is the <a href="#concept-input-step-default" title="concept-input-step-default">default step</a> multiplied
809: by the <a href="#concept-input-step-scale" title="concept-input-step-scale">step scale
810: factor</a>.</li>
811:
812: <li>Otherwise, the <a href="#concept-input-step" title="concept-input-step">allowed value
813: step</a> is the number returned by the <a href="common-microsyntaxes.html#rules-for-parsing-floating-point-number-values">rules for parsing
814: floating point number values</a> when they are applied to the
815: attribute's value, multiplied by the <a href="#concept-input-step-scale" title="concept-input-step-scale">step scale factor</a>.</li>
816:
817: </ol><p>The <dfn id="concept-input-min-zero" title="concept-input-min-zero">step base</dfn> is the
818: result of applying the <a href="the-input-element.html#concept-input-value-string-number" title="concept-input-value-string-number">algorithm to convert a
819: string to a number</a> to the value of the <code title="attr-input-min"><a href="#attr-input-min">min</a></code> attribute, unless the element does
820: not have a <code title="attr-input-min"><a href="#attr-input-min">min</a></code> attribute
821: specified or the result of applying that algorithm is an error, in
822: which case the <a href="#concept-input-min-zero" title="concept-input-min-zero">step base</a>
823: is the <a href="#concept-input-step-default-base" title="concept-input-step-default-base">default step
824: base</a>, if one is defined, or zero, if not.</p>
825:
826: <p><strong>Constraint validation</strong>: When the element has an
827: <a href="#concept-input-step" title="concept-input-step">allowed value step</a>, and the
828: result of applying the <a href="the-input-element.html#concept-input-value-string-number" title="concept-input-value-string-number">algorithm to convert a
829: string to a number</a> to the string given by the element's <a href="association-of-controls-and-forms.html#concept-fe-value" title="concept-fe-value">value</a> is a number, and that
830: number subtracted from the <a href="#concept-input-min-zero" title="concept-input-min-zero">step
831: base</a> is not an integral multiple of the <a href="#concept-input-step" title="concept-input-step">allowed value step</a>, the element is
832: <a href="association-of-controls-and-forms.html#suffering-from-a-step-mismatch">suffering from a step mismatch</a>.</p>
833:
834: </div><div class="example">
835:
836: <p>The following range control only accepts values in the range
837: 0..1, and allows 256 steps in that range:</p>
838:
839: <pre><input name=opacity type=range min=0 max=1 step=0.00392156863></pre>
840:
841: </div><div class="example">
842:
843: <p>The following control allows any time in the day to be selected,
844: with any accuracy (e.g. thousandth-of-a-second accuracy or
845: more):</p>
846:
847: <pre><input name=favtime type=time step=any></pre>
848:
849: <p>Normally, time controls are limited to an accuracy of one
850: minute.</p>
851:
852: </div><h6 id="the-placeholder-attribute"><span class="secno">4.10.7.2.11 </span>The <code title="attr-input-placeholder"><a href="#attr-input-placeholder">placeholder</a></code> attribute</h6><p class="XXX annotation"><b>Status: </b><i>Last call for comments</i></p><!-- similar text in the <textarea> section --><p>The <dfn id="attr-input-placeholder" title="attr-input-placeholder"><code>placeholder</code></dfn>
853: attribute represents a <em>short</em> hint (a word or short phrase)
854: intended to aid the user with data entry. A hint could be a sample
855: value or a brief description of the expected format. The attribute,
856: if specified, must have a value that contains no U+000A LINE FEED
857: (LF) or U+000D CARRIAGE RETURN (CR) characters.</p><p class="note">For a longer hint or other advisory text, the <code title="attr-title"><a href="elements.html#the-title-attribute">title</a></code> attribute is more appropriate.</p><p>The <code title="attr-input-placeholder"><a href="#attr-input-placeholder">placeholder</a></code>
858: attribute should not be used as an alternative to a
859: <code><a href="forms.html#the-label-element">label</a></code>.</p><div class="impl">
860:
861: <p>User agents should present this hint to the user, after having
862: <a href="common-microsyntaxes.html#strip-line-breaks" title="strip line breaks">stripped line breaks</a> from it,
863: when the element's <a href="association-of-controls-and-forms.html#concept-fe-value" title="concept-fe-value">value</a> is
864: the empty string and the control is not focused (e.g. by displaying
865: it inside a blank unfocused control).</p>
866:
867: </div><div class="example">
868:
869: <p>Here is an example of a mail configuration user interface that
870: uses the <code title="attr-input-placeholder"><a href="#attr-input-placeholder">placeholder</a></code>
871: attribute:</p>
872:
873: <pre><fieldset>
874: <legend>Mail Account</legend>
875: <p><label>Name: <input type="text" name="fullname" placeholder="John Ratzenberger"></label></p>
876: <p><label>Address: <input type="email" name="address" placeholder="john@example.net"></label></p>
877: <p><label>Password: <input type="password" name="password"></label></p>
878: <p><label>Description: <input type="text" name="desc" placeholder="My Email Account"></label></p>
879: </fieldset></pre>
880:
881: </div><h5 id="common-input-element-apis"><span class="secno">4.10.7.3 </span>Common <code><a href="the-input-element.html#the-input-element">input</a></code> element APIs</h5><p class="XXX annotation"><b>Status: </b><i>Last call for comments</i></p><dl class="domintro"><dt><var title="">input</var> . <code title="dom-input-value"><a href="#dom-input-value">value</a></code> [ = <var title="">value</var> ]</dt>
882:
883: <dd>
884:
885: <p>Returns the current <a href="association-of-controls-and-forms.html#concept-fe-value" title="concept-fe-value">value</a>
886: of the form control.</p>
887:
888: <p>Can be set, to change the value.</p>
889:
890: <p>Throws an <code><a href="common-dom-interfaces.html#invalid_state_err">INVALID_STATE_ERR</a></code> exception if it is
891: set to any value other than the empty string when the control is a
892: file upload control.</p>
893:
894: </dd>
895:
896: <dt><var title="">input</var> . <code title="dom-input-checked"><a href="#dom-input-checked">checked</a></code> [ = <var title="">value</var> ]</dt>
897:
898: <dd>
899:
900: <p>Returns the current <a href="association-of-controls-and-forms.html#concept-fe-checked" title="concept-fe-checked">checkedness</a> of the form
901: control.</p>
902:
903: <p>Can be set, to change the <a href="association-of-controls-and-forms.html#concept-fe-checked" title="concept-fe-checked">checkedness</a>.</p>
904:
905: </dd>
906:
907: <dt><var title="">input</var> . <code title="dom-input-files"><a href="#dom-input-files">files</a></code></dt>
908:
909: <dd>
910:
911: <p>Returns a <code>FileList</code> object listing the <a href="number-state.html#concept-input-type-file-selected" title="concept-input-type-file-selected">selected files</a> of
912: the form control.</p>
913:
1.7 ! mike 914: <p>Returns null if the control isn't a file control.</p>
1.1 mike 915:
916: </dd>
917:
918: <dt><var title="">input</var> . <code title="dom-input-valueAsDate"><a href="#dom-input-valueasdate">valueAsDate</a></code> [ = <var title="">value</var> ]</dt>
919:
920: <dd>
921:
922: <p>Returns a <code>Date</code> object representing the form
923: control's <a href="association-of-controls-and-forms.html#concept-fe-value" title="concept-fe-value">value</a>, if
924: applicable; otherwise, returns null.</p>
925:
926: <p>Can be set, to change the value.</p>
927:
928: <p>Throws an <code><a href="common-dom-interfaces.html#invalid_state_err">INVALID_STATE_ERR</a></code> exception if the
929: control isn't date- or time-based.</p>
930:
931: </dd>
932:
933: <dt><var title="">input</var> . <code title="dom-input-valueAsNumber"><a href="#dom-input-valueasnumber">valueAsNumber</a></code> [ = <var title="">value</var> ]</dt>
934:
935: <dd>
936:
937: <p>Returns a number representing the form control's <a href="association-of-controls-and-forms.html#concept-fe-value" title="concept-fe-value">value</a>, if applicable; otherwise,
938: returns null.</p>
939:
940: <p>Can be set, to change the value.</p>
941:
942: <p>Throws an <code><a href="common-dom-interfaces.html#invalid_state_err">INVALID_STATE_ERR</a></code> exception if the
943: control is neither date- or time-based nor numeric.</p>
944:
945: </dd>
946:
947: <dt><var title="">input</var> . <code title="dom-input-stepUp"><a href="#dom-input-stepup">stepUp</a></code>( [ <var title="">n</var> ] )</dt>
948: <dt><var title="">input</var> . <code title="dom-input-stepDown"><a href="#dom-input-stepdown">stepDown</a></code>( [ <var title="">n</var> ] )</dt>
949:
950: <dd>
951:
952: <p>Changes the form control's <a href="association-of-controls-and-forms.html#concept-fe-value" title="concept-fe-value">value</a> by the value given in the
953: <code title="attr-input-step"><a href="#attr-input-step">step</a></code> attribute, multiplied by
954: <var title="">n</var>. The default is 1.</p>
955:
956: <p>Throws <code><a href="common-dom-interfaces.html#invalid_state_err">INVALID_STATE_ERR</a></code> exception if the control
957: is neither date- or time-based nor numeric, if the <code title="attr-input-step"><a href="#attr-input-step">step</a></code> attribute's value is "<code title="">any</code>", if the current <a href="association-of-controls-and-forms.html#concept-fe-value" title="concept-fe-value">value</a> could not be parsed, or if
958: stepping in the given direction by the given amount would take the
959: value out of range.</p>
960:
961: </dd>
962:
963: <dt><var title="">input</var> . <code title="dom-input-list"><a href="#dom-input-list">list</a></code></dt>
964:
965: <dd>
966:
967: <p>Returns the <code><a href="the-button-element.html#the-datalist-element">datalist</a></code> element indicated by the
968: <code title="attr-input-list"><a href="#attr-input-list">list</a></code> attribute.</p>
969:
970: </dd>
971:
972: <dt><var title="">input</var> . <code title="dom-input-selectedOption"><a href="#dom-input-selectedoption">selectedOption</a></code></dt>
973:
974: <dd>
975:
976: <p>Returns the <code><a href="the-button-element.html#the-option-element">option</a></code> element from the
977: <code><a href="the-button-element.html#the-datalist-element">datalist</a></code> element indicated by the <code title="attr-input-list"><a href="#attr-input-list">list</a></code> attribute that matches the
978: form control's <a href="association-of-controls-and-forms.html#concept-fe-value" title="concept-fe-value">value</a>.</p>
979:
980: </dd>
981:
982: </dl><div class="impl">
983:
984: <p>The <dfn id="dom-input-value" title="dom-input-value"><code>value</code></dfn> IDL
985: attribute allows scripts to manipulate the <a href="association-of-controls-and-forms.html#concept-fe-value" title="concept-fe-value">value</a> of an <code><a href="the-input-element.html#the-input-element">input</a></code>
986: element. The attribute is in one of the following modes, which
987: define its behavior:</p>
988:
989: <dl><dt><dfn id="dom-input-value-value" title="dom-input-value-value">value</dfn>
990:
991: </dt><dd>On getting, it must return the current <a href="association-of-controls-and-forms.html#concept-fe-value" title="concept-fe-value">value</a> of the element. On setting,
992: it must set the element's <a href="association-of-controls-and-forms.html#concept-fe-value" title="concept-fe-value">value</a> to the new value, set the
993: element's <a href="the-input-element.html#concept-input-value-dirty-flag" title="concept-input-value-dirty-flag">dirty value
994: flag</a> to true, and then invoke the <a href="the-input-element.html#value-sanitization-algorithm">value sanitization
995: algorithm</a>, if the element's <code title="attr-input-type"><a href="the-input-element.html#attr-input-type">type</a></code> attribute's current state
996: defines one.</dd>
997:
998: <dt><dfn id="dom-input-value-default" title="dom-input-value-default">default</dfn>
999:
1000: </dt><dd>On getting, if the element has a <code title="attr-input-value"><a href="the-input-element.html#attr-input-value">value</a></code> attribute, it must return
1001: that attribute's value; otherwise, it must return the empty
1002: string. On setting, it must set the element's <code title="attr-input-value"><a href="the-input-element.html#attr-input-value">value</a></code> attribute to the new
1003: value.</dd>
1004:
1005: <dt><dfn id="dom-input-value-default-on" title="dom-input-value-default-on">default/on</dfn>
1006:
1007: </dt><dd>On getting, if the element has a <code title="attr-input-value"><a href="the-input-element.html#attr-input-value">value</a></code> attribute, it must return
1008: that attribute's value; otherwise, it must return the string "<code title="">on</code>". On setting, it must set the element's <code title="attr-input-value"><a href="the-input-element.html#attr-input-value">value</a></code> attribute to the new
1009: value.</dd>
1010:
1011: <dt><dfn id="dom-input-value-filename" title="dom-input-value-filename">filename</dfn>
1012:
1013: </dt><dd>On getting, it must return the string "<code title="">C:\fakepath\</code>" followed by the filename of the first
1014: file in the list of <a href="number-state.html#concept-input-type-file-selected" title="concept-input-type-file-selected">selected files</a>, if
1015: any, or the empty string if the list is empty. On setting, if the
1016: new value is the empty string, it must empty the list of <a href="number-state.html#concept-input-type-file-selected" title="concept-input-type-file-selected">selected files</a>;
1017: otherwise, it must throw an <code><a href="common-dom-interfaces.html#invalid_state_err">INVALID_STATE_ERR</a></code>
1018: exception.</dd>
1019:
1020: </dl><hr><p>The <dfn id="dom-input-checked" title="dom-input-checked"><code>checked</code></dfn> IDL
1021: attribute allows scripts to manipulate the <a href="association-of-controls-and-forms.html#concept-fe-checked" title="concept-fe-checked">checkedness</a> of an
1022: <code><a href="the-input-element.html#the-input-element">input</a></code> element. On getting, it must return the current
1023: <a href="association-of-controls-and-forms.html#concept-fe-checked" title="concept-fe-checked">checkedness</a> of the element;
1024: and on setting, it must set the element's <a href="association-of-controls-and-forms.html#concept-fe-checked" title="concept-fe-checked">checkedness</a> to the new value and
1025: set the element's <a href="the-input-element.html#concept-input-checked-dirty-flag" title="concept-input-checked-dirty-flag">dirty checkedness
1026: flag</a> to true.</p>
1027:
1028: <hr><p>The <dfn id="dom-input-files" title="dom-input-files"><code>files</code></dfn> IDL
1029: attribute allows scripts to access the element's <a href="number-state.html#concept-input-type-file-selected" title="concept-input-type-file-selected">selected files</a>. On
1030: getting, if the IDL attribute applies, it must return a
1031: <code>FileList</code> object that represents the current <a href="number-state.html#concept-input-type-file-selected" title="concept-input-type-file-selected">selected files</a>. The
1032: same object must be returned until the list of <a href="number-state.html#concept-input-type-file-selected" title="concept-input-type-file-selected">selected files</a>
1033: changes. If the IDL attribute does not apply, then it must instead
1.7 ! mike 1034: return null. <a href="references.html#refsFILEAPI">[FILEAPI]</a></p>
1.1 mike 1035:
1036: <hr><p>The <dfn id="dom-input-valueasdate" title="dom-input-valueAsDate"><code>valueAsDate</code></dfn> IDL
1037: attribute represents the <a href="association-of-controls-and-forms.html#concept-fe-value" title="concept-fe-value">value</a> of the element, interpreted
1038: as a date.</p>
1039:
1040: <p>On getting, if the <code title="dom-input-valueAsDate"><a href="#dom-input-valueasdate">valueAsDate</a></code> attribute does not
1041: apply, as defined for the <code><a href="the-input-element.html#the-input-element">input</a></code> element's <code title="attr-input-type"><a href="the-input-element.html#attr-input-type">type</a></code> attribute's current state, then
1042: return null. Otherwise, run the <a href="the-input-element.html#concept-input-value-string-date" title="concept-input-value-string-date">algorithm to convert a
1043: string to a <code>Date</code> object</a> defined for that state;
1044: if the algorithm returned a <code>Date</code> object, then return
1045: it, otherwise, return null.</p>
1046:
1047: <p>On setting, if the <code title="dom-input-valueAsDate"><a href="#dom-input-valueasdate">valueAsDate</a></code> attribute does not
1048: apply, as defined for the <code><a href="the-input-element.html#the-input-element">input</a></code> element's <code title="attr-input-type"><a href="the-input-element.html#attr-input-type">type</a></code> attribute's current state, then
1049: throw an <code><a href="common-dom-interfaces.html#invalid_state_err">INVALID_STATE_ERR</a></code> exception; otherwise, if
1050: the new value is null, then set the <a href="association-of-controls-and-forms.html#concept-fe-value" title="concept-fe-value">value</a> of the element to the empty
1051: string; otherwise, run the <a href="the-input-element.html#concept-input-value-date-string" title="concept-input-value-date-string">algorithm to convert a
1052: <code>Date</code> object to a string</a>, as defined for that
1053: state, on the new value, and set the <a href="association-of-controls-and-forms.html#concept-fe-value" title="concept-fe-value">value</a> of the element to resulting
1054: string.</p>
1055:
1056: <hr><p>The <dfn id="dom-input-valueasnumber" title="dom-input-valueAsNumber"><code>valueAsNumber</code></dfn> IDL
1057: attribute represents the <a href="association-of-controls-and-forms.html#concept-fe-value" title="concept-fe-value">value</a>
1058: of the element, interpreted as a number.</p>
1059:
1060: <p>On getting, if the <code title="dom-input-valueAsNumber"><a href="#dom-input-valueasnumber">valueAsNumber</a></code> attribute does
1061: not apply, as defined for the <code><a href="the-input-element.html#the-input-element">input</a></code> element's <code title="attr-input-type"><a href="the-input-element.html#attr-input-type">type</a></code> attribute's current state, then
1062: return a Not-a-Number (NaN) value. Otherwise, if the <code title="dom-input-valueAsDate"><a href="#dom-input-valueasdate">valueAs<em>Date</em></a></code>
1063: attribute applies, run the <a href="the-input-element.html#concept-input-value-string-date" title="concept-input-value-string-date">algorithm to convert a
1064: string to a <code>Date</code> object</a> defined for that state;
1065: if the algorithm returned a <code>Date</code> object, then return
1066: the <i>time value</i> of the object (the number of milliseconds from
1067: midnight UTC the morning of 1970-01-01 to the time represented by
1068: the <code>Date</code> object), otherwise, return a Not-a-Number
1069: (NaN) value. Otherwise, run the <a href="the-input-element.html#concept-input-value-string-number" title="concept-input-value-string-number">algorithm to convert a
1070: string to a number</a> defined for that state; if the algorithm
1071: returned a number, then return it, otherwise, return a Not-a-Number
1072: (NaN) value.</p>
1073:
1074: <p>On setting, if the <code title="dom-input-valueAsNumber"><a href="#dom-input-valueasnumber">valueAsNumber</a></code> attribute does
1075: not apply, as defined for the <code><a href="the-input-element.html#the-input-element">input</a></code> element's <code title="attr-input-type"><a href="the-input-element.html#attr-input-type">type</a></code> attribute's current state, then
1076: throw an <code><a href="common-dom-interfaces.html#invalid_state_err">INVALID_STATE_ERR</a></code> exception. Otherwise, if
1077: the <code title="dom-input-valueAsDate"><a href="#dom-input-valueasdate">valueAs<em>Date</em></a></code>
1078: attribute applies, run the <a href="the-input-element.html#concept-input-value-date-string" title="concept-input-value-date-string">algorithm to convert a
1079: <code>Date</code> object to a string</a> defined for that state,
1080: passing it a <code>Date</code> object whose <i>time value</i> is the
1081: new value, and set the <a href="association-of-controls-and-forms.html#concept-fe-value" title="concept-fe-value">value</a>
1082: of the element to resulting string. Otherwise, run the <a href="the-input-element.html#concept-input-value-number-string" title="concept-input-value-number-string">algorithm to convert a
1083: number to a string</a>, as defined for that state, on the new
1084: value, and set the <a href="association-of-controls-and-forms.html#concept-fe-value" title="concept-fe-value">value</a> of
1085: the element to resulting string.</p>
1086:
1087: <hr><p>The <dfn id="dom-input-stepdown" title="dom-input-stepDown"><code>stepDown(<var title="">n</var>)</code></dfn> and <dfn id="dom-input-stepup" title="dom-input-stepUp"><code>stepUp(<var title="">n</var>)</code></dfn> methods, when invoked, must run the
1088: following algorithm:</p>
1089:
1090: <ol><li><p>If the <code title="dom-input-stepDown"><a href="#dom-input-stepdown">stepDown()</a></code> and
1091: <code title="dom-input-stepUp"><a href="#dom-input-stepup">stepUp()</a></code> methods do not
1092: apply, as defined for the <code><a href="the-input-element.html#the-input-element">input</a></code> element's <code title="attr-input-type"><a href="the-input-element.html#attr-input-type">type</a></code> attribute's current state, then
1093: throw an <code><a href="common-dom-interfaces.html#invalid_state_err">INVALID_STATE_ERR</a></code> exception, and abort these
1094: steps.</p></li>
1095:
1096: <li><p>If the element has no <a href="#concept-input-step" title="concept-input-step">allowed value step</a>, then throw an
1097: <code><a href="common-dom-interfaces.html#invalid_state_err">INVALID_STATE_ERR</a></code> exception, and abort these
1098: steps.</p></li>
1099:
1100: <li><p>If applying the <a href="the-input-element.html#concept-input-value-string-number" title="concept-input-value-string-number">algorithm to convert a
1101: string to a number</a> to the string given by the element's
1102: <a href="association-of-controls-and-forms.html#concept-fe-value" title="concept-fe-value">value</a> results in an error,
1103: then throw an <code><a href="common-dom-interfaces.html#invalid_state_err">INVALID_STATE_ERR</a></code> exception, and abort
1104: these steps; otherwise, let <var title="">value</var> be the result
1105: of that algorithm.</p></li>
1106:
1107: <li><p>Let <var title="">n</var> be the argument, or 1 if the
1108: argument was omitted.</p></li>
1109:
1110: <li><p>Let <var title="">delta</var> be the <a href="#concept-input-step" title="concept-input-step">allowed value step</a> multiplied by
1111: <var title="">n</var>.</p></li>
1112:
1113: <li><p>If the method invoked was the <code title="dom-input-stepDown"><a href="#dom-input-stepdown">stepDown()</a></code> method, negate <var title="">delta</var>.</p></li>
1114:
1115: <li><p>Let <var title="">value</var> be the result of adding <var title="">delta</var> to <var title="">value</var>.</p></li>
1116: <li><p>If the element has a <a href="#concept-input-min" title="concept-input-min">minimum</a>, and the <var title="">value</var> is less than that <a href="#concept-input-min" title="concept-input-min">minimum</a>, then throw a
1117: <code><a href="common-dom-interfaces.html#invalid_state_err">INVALID_STATE_ERR</a></code> exception.</p></li>
1118:
1119: <li><p>If the element has a <a href="#concept-input-max" title="concept-input-max">maximum</a>, and the <var title="">value</var> is greater than that <a href="#concept-input-max" title="concept-input-max">maximum</a>, then throw a
1120: <code><a href="common-dom-interfaces.html#invalid_state_err">INVALID_STATE_ERR</a></code> exception.</p></li>
1121:
1122: <li><p>Let <var title="">value as string</var> be the result of
1123: running the <a href="the-input-element.html#concept-input-value-number-string" title="concept-input-value-number-string">algorithm to convert a
1124: number to a string</a>, as defined for the <code><a href="the-input-element.html#the-input-element">input</a></code>
1125: element's <code title="attr-input-type"><a href="the-input-element.html#attr-input-type">type</a></code> attribute's
1126: current state, on <var title="">value</var>.</p></li>
1127:
1128: <li><p>Set the <a href="association-of-controls-and-forms.html#concept-fe-value" title="concept-fe-value">value</a> of the
1129: element to <var title="">value as string</var>.</p></li>
1130:
1131: </ol><hr><p>The <dfn id="dom-input-list" title="dom-input-list"><code>list</code></dfn> IDL
1132: attribute must return the current <a href="#concept-input-list" title="concept-input-list">suggestions source element</a>, if
1133: any, or null otherwise.</p>
1134:
1135: <p>The <dfn id="dom-input-selectedoption" title="dom-input-selectedOption"><code>selectedOption</code></dfn>
1136: IDL attribute must return the first <code><a href="the-button-element.html#the-option-element">option</a></code> element, in
1137: <a href="infrastructure.html#tree-order">tree order</a>, to be a child of the <a href="#concept-input-list" title="concept-input-list">suggestions source element</a> and
1138: whose <a href="the-button-element.html#concept-option-value" title="concept-option-value">value</a> matches the
1139: <code><a href="the-input-element.html#the-input-element">input</a></code> element's <a href="association-of-controls-and-forms.html#concept-fe-value" title="concept-fe-value">value</a>, if any. If there is no <a href="#concept-input-list" title="concept-input-list">suggestions source element</a>, or if
1140: it contains no matching <code><a href="the-button-element.html#the-option-element">option</a></code> element, then the <code title="dom-input-selectedOption"><a href="#dom-input-selectedoption">selectedOption</a></code> attribute
1141: must return null.</p>
1142:
1143: </div><div class="impl">
1144:
1145: <h5 id="common-event-behaviors"><span class="secno">4.10.7.4 </span>Common event behaviors</h5><p class="XXX annotation"><b>Status: </b><i>Last call for comments</i></p>
1146:
1147: <p>When the <dfn id="event-input-input" title="event-input-input"><code>input</code></dfn>
1148: event applies, any time the user causes the element's <a href="association-of-controls-and-forms.html#concept-fe-value" title="concept-fe-value">value</a> to change, the user agent must
1149: <a href="webappapis.html#queue-a-task">queue a task</a> to <a href="webappapis.html#fire-a-simple-event">fire a simple event</a> that
1150: bubbles named <code title="event-input">input</code> at the
1151: <code><a href="the-input-element.html#the-input-element">input</a></code> element, then <a href="association-of-controls-and-forms.html#broadcast-forminput-events">broadcast <code title="event-forminput">forminput</code> events</a> at the
1152: <code><a href="the-input-element.html#the-input-element">input</a></code> element's <a href="association-of-controls-and-forms.html#form-owner">form owner</a>. User agents
1153: may wait for a suitable break in the user's interaction before
1154: queuing the task; for example, a user agent could wait for the user
1155: to have not hit a key for 100ms, so as to only fire the event when
1156: the user pauses, instead of continuously for each keystroke.</p>
1157: <!-- same text is present in the <textarea> section -->
1158:
1159: <p class="example">Examples of a user changing the element's <a href="association-of-controls-and-forms.html#concept-fe-value" title="concept-fe-value">value</a> would include the user typing
1160: into a text field, pasting a new value into the field, or undoing an
1161: edit in that field. Some user interactions do not cause changes to
1162: the value, e.g. hitting the "delete" key in an empty text field, or
1163: replacing some text in the field with text from the clipboard that
1164: happens to be exactly the same text.</p>
1165:
1166: <p>When the <dfn id="event-input-change" title="event-input-change"><code>change</code></dfn> event applies,
1167: if the element does not have an <a href="content-models.html#activation-behavior">activation behavior</a>
1168: defined but uses a user interface that involves an explicit commit
1169: action, then any time the user commits a change to the element's
1170: <a href="association-of-controls-and-forms.html#concept-fe-value" title="concept-fe-value">value</a> or list of <a href="number-state.html#concept-input-type-file-selected" title="concept-input-type-file-selected">selected files</a>, the
1171: user agent must <a href="webappapis.html#queue-a-task">queue a task</a> to <a href="webappapis.html#fire-a-simple-event">fire a simple
1172: event</a> that bubbles named <code title="event-change">change</code> at the <code><a href="the-input-element.html#the-input-element">input</a></code>
1173: element, then <a href="association-of-controls-and-forms.html#broadcast-formchange-events">broadcast <code title="event-formchange">formchange</code> events</a> at the
1174: <code><a href="the-input-element.html#the-input-element">input</a></code> element's <a href="association-of-controls-and-forms.html#form-owner">form owner</a>.</p>
1175:
1176: <p class="example">An example of a user interface with a commit
1177: action would be a <a href="number-state.html#file-upload-state" title="attr-input-type-file">File
1178: Upload</a> control that consists of a single button that brings
1179: up a file selection dialog: when the dialog is closed, if that the
1180: <a href="number-state.html#concept-input-type-file-selected" title="concept-input-type-file-selected">file selection</a>
1181: changed as a result, then the user has committed a new <a href="number-state.html#concept-input-type-file-selected" title="concept-input-type-file-selected">file selection</a>.</p>
1182:
1183: <p class="example">Another example of a user interface with a commit
1184: action would be a <a href="states-of-the-type-attribute.html#date-state" title="attr-input-type-date">Date</a>
1185: control that allows both text-based user input and user selection
1186: from a drop-down calendar: while text input might not have an
1187: explicit commit step, selecting a date from the drop down calendar
1188: and then dismissing the drop down would be a commit action.</p>
1189:
1190: <p>When the user agent changes the element's <a href="association-of-controls-and-forms.html#concept-fe-value" title="concept-fe-value">value</a> on behalf of the user (e.g. as
1191: part of a form prefilling feature), the user agent must follow these
1192: steps:</p>
1193:
1194: <ol><li>If the <code title="event-input-input"><a href="#event-input-input">input</a></code> event
1195: applies, <a href="webappapis.html#queue-a-task">queue a task</a> to <a href="webappapis.html#fire-a-simple-event">fire a simple
1196: event</a> that bubbles named <code title="event-input">input</code> at the <code><a href="the-input-element.html#the-input-element">input</a></code>
1197: element.</li>
1198:
1199: <li>If the <code title="event-input-input"><a href="#event-input-input">input</a></code> event
1200: applies, <a href="association-of-controls-and-forms.html#broadcast-forminput-events">broadcast <code title="event-forminput">forminput</code> events</a> at the
1201: <code><a href="the-input-element.html#the-input-element">input</a></code> element's <a href="association-of-controls-and-forms.html#form-owner">form owner</a>.</li>
1202:
1203: <li>If the <code title="event-input-change"><a href="#event-input-change">change</a></code> event
1204: applies, <a href="webappapis.html#queue-a-task">queue a task</a> to <a href="webappapis.html#fire-a-simple-event">fire a simple
1205: event</a> that bubbles named <code title="event-change">change</code> at the <code><a href="the-input-element.html#the-input-element">input</a></code>
1206: element.</li>
1207:
1208: <li>If the <code title="event-input-change"><a href="#event-input-change">change</a></code> event
1209: applies, <a href="association-of-controls-and-forms.html#broadcast-formchange-events">broadcast <code title="event-formchange">formchange</code> events</a> at the
1210: <code><a href="the-input-element.html#the-input-element">input</a></code> element's <a href="association-of-controls-and-forms.html#form-owner">form owner</a>.</li>
1211:
1212: </ol><p class="note">In addition, when the <code title="event-input-change"><a href="#event-input-change">change</a></code> event applies, <code title="event-change">change</code> events can also be fired as part
1213: of the element's <a href="content-models.html#activation-behavior">activation behavior</a> and as part of the
1214: <a href="editing.html#unfocusing-steps">unfocusing steps</a>.</p>
1215:
1216: <p>The <a href="webappapis.html#task-source">task source</a> for these <a href="webappapis.html#concept-task" title="concept-task">tasks</a> is the <a href="webappapis.html#user-interaction-task-source">user interaction task
1217: source</a>.</p>
1218:
1219: </div></body></html>
Webmaster