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