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