Annotation of html5/spec/common-input-element-attributes.html, revision 1.176

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

Webmaster