Policy 1707 commit to LF
[policy/engine.git] / POLICY-SDK-APP / src / main / webapp / app / policyApp / CSS / bootstrap / docs / _includes / css / forms.html
1 <div class="bs-docs-section">
2   <h1 id="forms" class="page-header">Forms</h1>
3
4   <h2 id="forms-example">Basic example</h2>
5   <p>Individual form controls automatically receive some global styling. All textual <code>&lt;input&gt;</code>, <code>&lt;textarea&gt;</code>, and <code>&lt;select&gt;</code> elements with <code>.form-control</code> are set to <code>width: 100%;</code> by default. Wrap labels and controls in <code>.form-group</code> for optimum spacing.</p>
6   <div class="bs-example" data-example-id="basic-forms">
7     <form>
8       <div class="form-group">
9         <label for="exampleInputEmail1">Email address</label>
10         <input type="email" class="form-control" id="exampleInputEmail1" placeholder="Enter email">
11       </div>
12       <div class="form-group">
13         <label for="exampleInputPassword1">Password</label>
14         <input type="password" class="form-control" id="exampleInputPassword1" placeholder="Password">
15       </div>
16       <div class="form-group">
17         <label for="exampleInputFile">File input</label>
18         <input type="file" id="exampleInputFile">
19         <p class="help-block">Example block-level help text here.</p>
20       </div>
21       <div class="checkbox">
22         <label>
23           <input type="checkbox"> Check me out
24         </label>
25       </div>
26       <button type="submit" class="btn btn-default">Submit</button>
27     </form>
28   </div><!-- /example -->
29 {% highlight html %}
30 <form>
31   <div class="form-group">
32     <label for="exampleInputEmail1">Email address</label>
33     <input type="email" class="form-control" id="exampleInputEmail1" placeholder="Enter email">
34   </div>
35   <div class="form-group">
36     <label for="exampleInputPassword1">Password</label>
37     <input type="password" class="form-control" id="exampleInputPassword1" placeholder="Password">
38   </div>
39   <div class="form-group">
40     <label for="exampleInputFile">File input</label>
41     <input type="file" id="exampleInputFile">
42     <p class="help-block">Example block-level help text here.</p>
43   </div>
44   <div class="checkbox">
45     <label>
46       <input type="checkbox"> Check me out
47     </label>
48   </div>
49   <button type="submit" class="btn btn-default">Submit</button>
50 </form>
51 {% endhighlight %}
52   <div class="bs-callout bs-callout-warning" id="callout-formgroup-inputgroup">
53     <h4>Don't mix form groups with input groups</h4>
54     <p>Do not mix form groups directly with <a href="/components/#input-groups">input groups</a>. Instead, nest the input group inside of the form group.</p>
55   </div>
56
57
58   <h2 id="forms-inline">Inline form</h2>
59   <p>Add <code>.form-inline</code> to your form (which doesn't have to be a <code>&lt;form&gt;</code>) for left-aligned and inline-block controls. <strong>This only applies to forms within viewports that are at least 768px wide.</strong></p>
60   <div class="bs-callout bs-callout-danger" id="callout-inline-form-width">
61     <h4>May require custom widths</h4>
62     <p>Inputs and selects have <code>width: 100%;</code> applied by default in Bootstrap. Within inline forms, we reset that to <code>width: auto;</code> so multiple controls can reside on the same line. Depending on your layout, additional custom widths may be required.</p>
63   </div>
64   <div class="bs-callout bs-callout-warning" id="callout-inline-form-labels">
65     <h4>Always add labels</h4>
66     <p>Screen readers will have trouble with your forms if you don't include a label for every input. For these inline forms, you can hide the labels using the <code>.sr-only</code> class. There are further alternative methods of providing a label for assistive technologies, such as the <code>aria-label</code>, <code>aria-labelledby</code> or <code>title</code> attribute. If none of these is present, screen readers may resort to using the <code>placeholder</code> attribute, if present, but note that use of <code>placeholder</code> as a replacement for other labelling methods is not advised.</p>
67   </div>
68
69   <div class="bs-example" data-example-id="simple-form-inline">
70     <form class="form-inline">
71       <div class="form-group">
72         <label for="exampleInputName2">Name</label>
73         <input type="text" class="form-control" id="exampleInputName2" placeholder="Jane Doe">
74       </div>
75       <div class="form-group">
76         <label for="exampleInputEmail2">Email</label>
77         <input type="email" class="form-control" id="exampleInputEmail2" placeholder="jane.doe@example.com">
78       </div>
79       <button type="submit" class="btn btn-default">Send invitation</button>
80     </form>
81   </div><!-- /example -->
82 {% highlight html %}
83 <form class="form-inline">
84   <div class="form-group">
85     <label for="exampleInputName2">Name</label>
86     <input type="text" class="form-control" id="exampleInputName2" placeholder="Jane Doe">
87   </div>
88   <div class="form-group">
89     <label for="exampleInputEmail2">Email</label>
90     <input type="email" class="form-control" id="exampleInputEmail2" placeholder="jane.doe@example.com">
91   </div>
92   <button type="submit" class="btn btn-default">Send invitation</button>
93 </form>
94 {% endhighlight %}
95
96   <div class="bs-example" data-example-id="simple-form-inline">
97     <form class="form-inline">
98       <div class="form-group">
99         <label class="sr-only" for="exampleInputEmail3">Email address</label>
100         <input type="email" class="form-control" id="exampleInputEmail3" placeholder="Enter email">
101       </div>
102       <div class="form-group">
103         <label class="sr-only" for="exampleInputPassword3">Password</label>
104         <input type="password" class="form-control" id="exampleInputPassword3" placeholder="Password">
105       </div>
106       <div class="checkbox">
107         <label>
108           <input type="checkbox"> Remember me
109         </label>
110       </div>
111       <button type="submit" class="btn btn-default">Sign in</button>
112     </form>
113   </div><!-- /example -->
114 {% highlight html %}
115 <form class="form-inline">
116   <div class="form-group">
117     <label class="sr-only" for="exampleInputEmail3">Email address</label>
118     <input type="email" class="form-control" id="exampleInputEmail3" placeholder="Enter email">
119   </div>
120   <div class="form-group">
121     <label class="sr-only" for="exampleInputPassword3">Password</label>
122     <input type="password" class="form-control" id="exampleInputPassword3" placeholder="Password">
123   </div>
124   <div class="checkbox">
125     <label>
126       <input type="checkbox"> Remember me
127     </label>
128   </div>
129   <button type="submit" class="btn btn-default">Sign in</button>
130 </form>
131 {% endhighlight %}
132
133   <div class="bs-example" data-example-id="form-inline-with-input-group">
134     <form class="form-inline">
135       <div class="form-group">
136         <label class="sr-only" for="exampleInputAmount">Amount (in dollars)</label>
137         <div class="input-group">
138           <div class="input-group-addon">$</div>
139           <input type="text" class="form-control" id="exampleInputAmount" placeholder="Amount">
140           <div class="input-group-addon">.00</div>
141         </div>
142       </div>
143       <button type="submit" class="btn btn-primary">Transfer cash</button>
144     </form>
145   </div><!-- /example -->
146 {% highlight html %}
147 <form class="form-inline">
148   <div class="form-group">
149     <label class="sr-only" for="exampleInputAmount">Amount (in dollars)</label>
150     <div class="input-group">
151       <div class="input-group-addon">$</div>
152       <input type="text" class="form-control" id="exampleInputAmount" placeholder="Amount">
153       <div class="input-group-addon">.00</div>
154     </div>
155   </div>
156   <button type="submit" class="btn btn-primary">Transfer cash</button>
157 </form>
158 {% endhighlight %}
159
160   <h2 id="forms-horizontal">Horizontal form</h2>
161   <p>Use Bootstrap's predefined grid classes to align labels and groups of form controls in a horizontal layout by adding <code>.form-horizontal</code> to the form (which doesn't have to be a <code>&lt;form&gt;</code>). Doing so changes <code>.form-group</code>s to behave as grid rows, so no need for <code>.row</code>.</p>
162   <div class="bs-example" data-example-id="simple-horizontal-form">
163     <form class="form-horizontal">
164       <div class="form-group">
165         <label for="inputEmail3" class="col-sm-2 control-label">Email</label>
166         <div class="col-sm-10">
167           <input type="email" class="form-control" id="inputEmail3" placeholder="Email">
168         </div>
169       </div>
170       <div class="form-group">
171         <label for="inputPassword3" class="col-sm-2 control-label">Password</label>
172         <div class="col-sm-10">
173           <input type="password" class="form-control" id="inputPassword3" placeholder="Password">
174         </div>
175       </div>
176       <div class="form-group">
177         <div class="col-sm-offset-2 col-sm-10">
178           <div class="checkbox">
179             <label>
180               <input type="checkbox"> Remember me
181             </label>
182           </div>
183         </div>
184       </div>
185       <div class="form-group">
186         <div class="col-sm-offset-2 col-sm-10">
187           <button type="submit" class="btn btn-default">Sign in</button>
188         </div>
189       </div>
190     </form>
191   </div><!-- /.bs-example -->
192 {% highlight html %}
193 <form class="form-horizontal">
194   <div class="form-group">
195     <label for="inputEmail3" class="col-sm-2 control-label">Email</label>
196     <div class="col-sm-10">
197       <input type="email" class="form-control" id="inputEmail3" placeholder="Email">
198     </div>
199   </div>
200   <div class="form-group">
201     <label for="inputPassword3" class="col-sm-2 control-label">Password</label>
202     <div class="col-sm-10">
203       <input type="password" class="form-control" id="inputPassword3" placeholder="Password">
204     </div>
205   </div>
206   <div class="form-group">
207     <div class="col-sm-offset-2 col-sm-10">
208       <div class="checkbox">
209         <label>
210           <input type="checkbox"> Remember me
211         </label>
212       </div>
213     </div>
214   </div>
215   <div class="form-group">
216     <div class="col-sm-offset-2 col-sm-10">
217       <button type="submit" class="btn btn-default">Sign in</button>
218     </div>
219   </div>
220 </form>
221 {% endhighlight %}
222
223
224   <h2 id="forms-controls">Supported controls</h2>
225   <p>Examples of standard form controls supported in an example form layout.</p>
226
227   <h3>Inputs</h3>
228   <p>Most common form control, text-based input fields. Includes support for all HTML5 types: <code>text</code>, <code>password</code>, <code>datetime</code>, <code>datetime-local</code>, <code>date</code>, <code>month</code>, <code>time</code>, <code>week</code>, <code>number</code>, <code>email</code>, <code>url</code>, <code>search</code>, <code>tel</code>, and <code>color</code>.</p>
229   <div class="bs-callout bs-callout-danger" id="callout-input-needs-type">
230     <h4>Type declaration required</h4>
231     <p>Inputs will only be fully styled if their <code>type</code> is properly declared.</p>
232   </div>
233   <div class="bs-example" data-example-id="text-form-control">
234     <form>
235       <input type="text" class="form-control" placeholder="Text input">
236     </form>
237   </div><!-- /.bs-example -->
238 {% highlight html %}
239 <input type="text" class="form-control" placeholder="Text input">
240 {% endhighlight %}
241   <div class="bs-callout bs-callout-info" id="callout-xref-input-group">
242     <h4>Input groups</h4>
243     <p>To add integrated text or buttons before and/or after any text-based <code>&lt;input&gt;</code>, <a href="../components/#input-groups">check out the input group component</a>.</p>
244   </div>
245
246   <h3>Textarea</h3>
247   <p>Form control which supports multiple lines of text. Change <code>rows</code> attribute as necessary.</p>
248   <div class="bs-example" data-example-id="textarea-form-control">
249     <form>
250       <textarea class="form-control" rows="3" placeholder="Textarea"></textarea>
251     </form>
252   </div><!-- /.bs-example -->
253 {% highlight html %}
254 <textarea class="form-control" rows="3"></textarea>
255 {% endhighlight %}
256
257   <h3>Checkboxes and radios</h3>
258   <p>Checkboxes are for selecting one or several options in a list, while radios are for selecting one option from many.</p>
259   <p>A checkbox or radio with the <code>disabled</code> attribute will be styled appropriately. To have the <code>&lt;label&gt;</code> for the checkbox or radio also display a "not-allowed" cursor when the user hovers over the label, add the <code>.disabled</code> class to your <code>.radio</code>, <code>.radio-inline</code>, <code>.checkbox</code>, <code>.checkbox-inline</code>, or <code>&lt;fieldset&gt;</code>.</p>
260   <h4>Default (stacked)</h4>
261   <div class="bs-example" data-example-id="block-checkboxes-radios">
262     <form>
263       <div class="checkbox">
264         <label>
265           <input type="checkbox" value="">
266           Option one is this and that&mdash;be sure to include why it's great
267         </label>
268       </div>
269       <div class="checkbox disabled">
270         <label>
271           <input type="checkbox" value="" disabled>
272           Option two is disabled
273         </label>
274       </div>
275       <br>
276       <div class="radio">
277         <label>
278           <input type="radio" name="optionsRadios" id="optionsRadios1" value="option1" checked>
279           Option one is this and that&mdash;be sure to include why it's great
280         </label>
281       </div>
282       <div class="radio">
283         <label>
284           <input type="radio" name="optionsRadios" id="optionsRadios2" value="option2">
285           Option two can be something else and selecting it will deselect option one
286         </label>
287       </div>
288       <div class="radio disabled">
289         <label>
290           <input type="radio" name="optionsRadios" id="optionsRadios3" value="option3" disabled>
291           Option three is disabled
292         </label>
293       </div>
294     </form>
295   </div><!-- /.bs-example -->
296 {% highlight html %}
297 <div class="checkbox">
298   <label>
299     <input type="checkbox" value="">
300     Option one is this and that&mdash;be sure to include why it's great
301   </label>
302 </div>
303 <div class="checkbox disabled">
304   <label>
305     <input type="checkbox" value="" disabled>
306     Option two is disabled
307   </label>
308 </div>
309
310 <div class="radio">
311   <label>
312     <input type="radio" name="optionsRadios" id="optionsRadios1" value="option1" checked>
313     Option one is this and that&mdash;be sure to include why it's great
314   </label>
315 </div>
316 <div class="radio">
317   <label>
318     <input type="radio" name="optionsRadios" id="optionsRadios2" value="option2">
319     Option two can be something else and selecting it will deselect option one
320   </label>
321 </div>
322 <div class="radio disabled">
323   <label>
324     <input type="radio" name="optionsRadios" id="optionsRadios3" value="option3" disabled>
325     Option three is disabled
326   </label>
327 </div>
328 {% endhighlight %}
329
330   <h4>Inline checkboxes and radios</h4>
331   <p>Use the <code>.checkbox-inline</code> or <code>.radio-inline</code> classes on a series of checkboxes or radios for controls that appear on the same line.</p>
332   <div class="bs-example" data-example-id="inline-checkboxes-radios">
333     <form>
334       <label class="checkbox-inline">
335         <input type="checkbox" id="inlineCheckbox1" value="option1"> 1
336       </label>
337       <label class="checkbox-inline">
338         <input type="checkbox" id="inlineCheckbox2" value="option2"> 2
339       </label>
340       <label class="checkbox-inline">
341         <input type="checkbox" id="inlineCheckbox3" value="option3"> 3
342       </label>
343     </form>
344     <br>
345     <form>
346       <label class="radio-inline">
347         <input type="radio" name="inlineRadioOptions" id="inlineRadio1" value="option1"> 1
348       </label>
349       <label class="radio-inline">
350         <input type="radio" name="inlineRadioOptions" id="inlineRadio2" value="option2"> 2
351       </label>
352       <label class="radio-inline">
353         <input type="radio" name="inlineRadioOptions" id="inlineRadio3" value="option3"> 3
354       </label>
355     </form>
356   </div><!-- /.bs-example -->
357 {% highlight html %}
358 <label class="checkbox-inline">
359   <input type="checkbox" id="inlineCheckbox1" value="option1"> 1
360 </label>
361 <label class="checkbox-inline">
362   <input type="checkbox" id="inlineCheckbox2" value="option2"> 2
363 </label>
364 <label class="checkbox-inline">
365   <input type="checkbox" id="inlineCheckbox3" value="option3"> 3
366 </label>
367
368 <label class="radio-inline">
369   <input type="radio" name="inlineRadioOptions" id="inlineRadio1" value="option1"> 1
370 </label>
371 <label class="radio-inline">
372   <input type="radio" name="inlineRadioOptions" id="inlineRadio2" value="option2"> 2
373 </label>
374 <label class="radio-inline">
375   <input type="radio" name="inlineRadioOptions" id="inlineRadio3" value="option3"> 3
376 </label>
377 {% endhighlight %}
378
379   <h4>Checkboxes and radios without label text</h4>
380   <p>Should you have no text within the <code>&lt;label&gt;</code>, the input is positioned as you'd expect. <strong>Currently only works on non-inline checkboxes and radios.</strong> Remember to still provide some form of label for assistive technologies (for instance, using <code>aria-label</code>).</p>
381   <div class="bs-example" data-example-id="checkboxes-radios-without-labels">
382     <form>
383       <div class="checkbox">
384         <label>
385           <input type="checkbox" id="blankCheckbox" value="option1" aria-label="Checkbox without label text">
386         </label>
387       </div>
388       <div class="radio">
389         <label>
390           <input type="radio" name="blankRadio" id="blankRadio1" value="option1" aria-label="Radio button without label text">
391         </label>
392       </div>
393     </form>
394   </div>
395 {% highlight html %}
396 <div class="checkbox">
397   <label>
398     <input type="checkbox" id="blankCheckbox" value="option1" aria-label="...">
399   </label>
400 </div>
401 <div class="radio">
402   <label>
403     <input type="radio" name="blankRadio" id="blankRadio1" value="option1" aria-label="...">
404   </label>
405 </div>
406 {% endhighlight %}
407
408   <h3>Selects</h3>
409   <p>Note that many native select menus—namely in Safari and Chrome—have rounded corners that cannot be modified via <code>border-radius</code> properties.</p>
410   <div class="bs-example" data-example-ids="select-form-control">
411     <form>
412       <select class="form-control">
413         <option>1</option>
414         <option>2</option>
415         <option>3</option>
416         <option>4</option>
417         <option>5</option>
418       </select>
419     </form>
420   </div><!-- /.bs-example -->
421 {% highlight html %}
422 <select class="form-control">
423   <option>1</option>
424   <option>2</option>
425   <option>3</option>
426   <option>4</option>
427   <option>5</option>
428 </select>
429 {% endhighlight %}
430
431   <p>For <code>&lt;select&gt;</code> controls with the <code>multiple</code> attribute, multiple options are shown by default.</p>
432
433   <div class="bs-example" data-example-ids="select-multiple-form-control">
434     <form>
435       <select multiple class="form-control">
436         <option>1</option>
437         <option>2</option>
438         <option>3</option>
439         <option>4</option>
440         <option>5</option>
441       </select>
442     </form>
443   </div><!-- /.bs-example -->
444
445 {% highlight html %}
446 <select multiple class="form-control">
447   <option>1</option>
448   <option>2</option>
449   <option>3</option>
450   <option>4</option>
451   <option>5</option>
452 </select>
453 {% endhighlight %}
454
455
456   <h2 id="forms-controls-static">Static control</h2>
457   <p>When you need to place plain text next to a form label within a form, use the <code>.form-control-static</code> class on a <code>&lt;p&gt;</code>.</p>
458   <div class="bs-example" data-example-id="horizontal-static-form-control">
459     <form class="form-horizontal">
460       <div class="form-group">
461         <label class="col-sm-2 control-label">Email</label>
462         <div class="col-sm-10">
463           <p class="form-control-static">email@example.com</p>
464         </div>
465       </div>
466       <div class="form-group">
467         <label for="inputPassword" class="col-sm-2 control-label">Password</label>
468         <div class="col-sm-10">
469           <input type="password" class="form-control" id="inputPassword" placeholder="Password">
470         </div>
471       </div>
472     </form>
473   </div><!-- /.bs-example -->
474 {% highlight html %}
475 <form class="form-horizontal">
476   <div class="form-group">
477     <label class="col-sm-2 control-label">Email</label>
478     <div class="col-sm-10">
479       <p class="form-control-static">email@example.com</p>
480     </div>
481   </div>
482   <div class="form-group">
483     <label for="inputPassword" class="col-sm-2 control-label">Password</label>
484     <div class="col-sm-10">
485       <input type="password" class="form-control" id="inputPassword" placeholder="Password">
486     </div>
487   </div>
488 </form>
489 {% endhighlight %}
490   <div class="bs-example" data-example-id="inline-static-form-control">
491     <form class="form-inline">
492       <div class="form-group">
493         <label class="sr-only">Email</label>
494         <p class="form-control-static">email@example.com</p>
495       </div>
496       <div class="form-group">
497         <label for="inputPassword2" class="sr-only">Password</label>
498         <input type="password" class="form-control" id="inputPassword2" placeholder="Password">
499       </div>
500       <button type="submit" class="btn btn-default">Confirm identity</button>
501     </form>
502   </div>
503 {% highlight html %}
504 <form class="form-inline">
505   <div class="form-group">
506     <label class="sr-only">Email</label>
507     <p class="form-control-static">email@example.com</p>
508   </div>
509   <div class="form-group">
510     <label for="inputPassword2" class="sr-only">Password</label>
511     <input type="password" class="form-control" id="inputPassword2" placeholder="Password">
512   </div>
513   <button type="submit" class="btn btn-default">Confirm identity</button>
514 </form>
515 {% endhighlight %}
516
517   <h2 id="forms-control-focus">Focus state</h2>
518   <p>We remove the default <code>outline</code> styles on some form controls and apply a <code>box-shadow</code> in its place for <code>:focus</code>.</p>
519   <div class="bs-example">
520     <form>
521       <input class="form-control" id="focusedInput" type="text" value="Demonstrative focus state">
522     </form>
523   </div>
524   <div class="bs-callout bs-callout-info" id="callout-focus-demo">
525     <h4>Demo <code>:focus</code> state</h4>
526     <p>The above example input uses custom styles in our documentation to demonstrate the <code>:focus</code> state on a <code>.form-control</code>.</p>
527   </div>
528
529
530   <h2 id="forms-control-disabled">Disabled state</h2>
531   <p>Add the <code>disabled</code> boolean attribute on an input to prevent user interactions. Disabled inputs appear lighter and add a <code>not-allowed</code> cursor.</p>
532   <div class="bs-example" data-example-id="text-form-control-disabled">
533     <form>
534       <input class="form-control" id="disabledInput" type="text" placeholder="Disabled input here…" disabled>
535     </form>
536   </div><!-- /.bs-example -->
537 {% highlight html %}
538 <input class="form-control" id="disabledInput" type="text" placeholder="Disabled input here..." disabled>
539 {% endhighlight %}
540
541   <h3 id="forms-disabled-fieldsets">Disabled fieldsets</h3>
542   <p>Add the <code>disabled</code> attribute to a <code>&lt;fieldset&gt;</code> to disable all the controls within the <code>&lt;fieldset&gt;</code> at once.</p>
543
544   <div class="bs-callout bs-callout-warning" id="callout-fieldset-disabled-pointer-events">
545     <h4>Caveat about link functionality of <code>&lt;a&gt;</code></h4>
546     <p>By default, browsers will treat all native form controls (<code>&lt;input&gt;</code>, <code>&lt;select&gt;</code> and <code>&lt;button&gt;</code> elements) inside a <code>&lt;fieldset disabled&gt;</code> as disabled, preventing both keyboard and mouse interactions on them. However, if your form also includes <code>&lt;a ... class="btn btn-*"&gt;</code> elements, these will only be given a style of <code>pointer-events: none</code>. As noted in the section about <a href="#buttons-disabled">disabled state for buttons</a> (and specifically in the sub-section for anchor elements), this CSS property is not yet standardized and isn't fully supported in Opera 18 and below, or in Internet Explorer 11, and won't prevent keyboard users from being able to focus or activate these links. So to be safe, use custom JavaScript to disable such links.</p>
547   </div>
548
549   <div class="bs-callout bs-callout-danger" id="callout-fieldset-disabled-ie">
550     <h4>Cross-browser compatibility</h4>
551     <p>While Bootstrap will apply these styles in all browsers, Internet Explorer 11 and below don't fully support the <code>disabled</code> attribute on a <code>&lt;fieldset&gt;</code>. Use custom JavaScript to disable the fieldset in these browsers.</p>
552   </div>
553
554   <div class="bs-example" data-example-id="disabled-fieldset">
555     <form>
556       <fieldset disabled>
557         <div class="form-group">
558           <label for="disabledTextInput">Disabled input</label>
559           <input type="text" id="disabledTextInput" class="form-control" placeholder="Disabled input">
560         </div>
561         <div class="form-group">
562           <label for="disabledSelect">Disabled select menu</label>
563           <select id="disabledSelect" class="form-control">
564             <option>Disabled select</option>
565           </select>
566         </div>
567         <div class="checkbox">
568           <label>
569             <input type="checkbox"> Can't check this
570           </label>
571         </div>
572         <button type="submit" class="btn btn-primary">Submit</button>
573       </fieldset>
574     </form>
575   </div><!-- /.bs-example -->
576 {% highlight html %}
577 <form>
578   <fieldset disabled>
579     <div class="form-group">
580       <label for="disabledTextInput">Disabled input</label>
581       <input type="text" id="disabledTextInput" class="form-control" placeholder="Disabled input">
582     </div>
583     <div class="form-group">
584       <label for="disabledSelect">Disabled select menu</label>
585       <select id="disabledSelect" class="form-control">
586         <option>Disabled select</option>
587       </select>
588     </div>
589     <div class="checkbox">
590       <label>
591         <input type="checkbox"> Can't check this
592       </label>
593     </div>
594     <button type="submit" class="btn btn-primary">Submit</button>
595   </fieldset>
596 </form>
597 {% endhighlight %}
598
599
600   <h2 id="forms-control-readonly">Readonly state</h2>
601   <p>Add the <code>readonly</code> boolean attribute on an input to prevent modification of the input's value. Read-only inputs appear lighter (just like disabled inputs), but retain the standard cursor.</p>
602   <div class="bs-example" data-example-id="readonly-text-form-control">
603     <form>
604       <input class="form-control" type="text" placeholder="Readonly input here…" readonly>
605     </form>
606   </div><!-- /.bs-example -->
607 {% highlight html %}
608 <input class="form-control" type="text" placeholder="Readonly input here…" readonly>
609 {% endhighlight %}
610
611
612   <h2 id="forms-control-validation">Validation states</h2>
613   <p>Bootstrap includes validation styles for error, warning, and success states on form controls. To use, add <code>.has-warning</code>, <code>.has-error</code>, or <code>.has-success</code> to the parent element. Any <code>.control-label</code>, <code>.form-control</code>, and <code>.help-block</code> within that element will receive the validation styles.</p>
614
615   <div class="bs-callout bs-callout-warning" id="callout-form-validation-state-accessibility">
616     <h4>Conveying validation state to assistive technologies and colorblind users</h4>
617     <p>Using these validation styles to denote the state of a form control only provides a visual, color-based indication, which will not be conveyed to users of assistive technologies - such as screen readers - or to colorblind users.</p>
618     <p>Ensure that an alternative indication of state is also provided. For instance, you can include a hint about state in the form control's <code>&lt;label&gt;</code> text itself (as is the case in the following code example), include a <a href="../components/#glyphicons">Glyphicon</a> (with appropriate alternative text using the <code>.sr-only</code> class - see the <a href="../components/#glyphicons-examples">Glyphicon examples</a>), or by providing an additional <a href="#forms-help-text">help text</a> block. Specifically for assistive technologies, invalid form controls can also be assigned an <code>aria-invalid="true"</code> attribute.</p>
619   </div>
620
621   <div class="bs-example" data-example-id="form-validation-states">
622     <form>
623       <div class="form-group has-success">
624         <label class="control-label" for="inputSuccess1">Input with success</label>
625         <input type="text" class="form-control" id="inputSuccess1">
626       </div>
627       <div class="form-group has-warning">
628         <label class="control-label" for="inputWarning1">Input with warning</label>
629         <input type="text" class="form-control" id="inputWarning1">
630       </div>
631       <div class="form-group has-error">
632         <label class="control-label" for="inputError1">Input with error</label>
633         <input type="text" class="form-control" id="inputError1">
634       </div>
635       <div class="has-success">
636         <div class="checkbox">
637           <label>
638             <input type="checkbox" id="checkboxSuccess" value="option1">
639             Checkbox with success
640           </label>
641         </div>
642       </div>
643       <div class="has-warning">
644         <div class="checkbox">
645           <label>
646             <input type="checkbox" id="checkboxWarning" value="option1">
647             Checkbox with warning
648           </label>
649         </div>
650       </div>
651       <div class="has-error">
652         <div class="checkbox">
653           <label>
654             <input type="checkbox" id="checkboxError" value="option1">
655             Checkbox with error
656           </label>
657         </div>
658       </div>
659     </form>
660   </div><!-- /.bs-example -->
661 {% highlight html %}
662 <div class="form-group has-success">
663   <label class="control-label" for="inputSuccess1">Input with success</label>
664   <input type="text" class="form-control" id="inputSuccess1">
665 </div>
666 <div class="form-group has-warning">
667   <label class="control-label" for="inputWarning1">Input with warning</label>
668   <input type="text" class="form-control" id="inputWarning1">
669 </div>
670 <div class="form-group has-error">
671   <label class="control-label" for="inputError1">Input with error</label>
672   <input type="text" class="form-control" id="inputError1">
673 </div>
674 <div class="has-success">
675   <div class="checkbox">
676     <label>
677       <input type="checkbox" id="checkboxSuccess" value="option1">
678       Checkbox with success
679     </label>
680   </div>
681 </div>
682 <div class="has-warning">
683   <div class="checkbox">
684     <label>
685       <input type="checkbox" id="checkboxWarning" value="option1">
686       Checkbox with warning
687     </label>
688   </div>
689 </div>
690 <div class="has-error">
691   <div class="checkbox">
692     <label>
693       <input type="checkbox" id="checkboxError" value="option1">
694       Checkbox with error
695     </label>
696   </div>
697 </div>
698 {% endhighlight %}
699
700   <h3>With optional icons</h3>
701   <p>You can also add optional feedback icons with the addition of <code>.has-feedback</code> and the right icon.</p>
702   <p><strong class="text-danger">Feedback icons only work with textual <code>&lt;input class="form-control"&gt;</code> elements.</strong></p>
703   <div class="bs-callout bs-callout-warning" id="callout-has-feedback-icon-positioning">
704     <h4>Icons, labels, and input groups</h4>
705     <p>Manual positioning of feedback icons is required for inputs without a label and for <a href="../components#input-groups">input groups</a> with an add-on on the right. You are strongly encouraged to provide labels for all inputs for accessibility reasons. If you wish to prevent labels from being displayed, hide them with the <code>.sr-only</code> class. If you must do without labels, adjust the <code>top</code> value of the feedback icon. For input groups, adjust the <code>right</code> value to an appropriate pixel value depending on the width of your addon.</p>
706   </div>
707   <div class="bs-callout bs-callout-warning" id="callout-has-feedback-icon-accessibility">
708     <h4>Conveying the icon's meaning to assistive technologies</h4>
709     <p>To ensure that assistive technologies – such as screen readers – correctly convey the meaning of an icon, additional hidden text should be included with the <code>.sr-only</code> class and explicitly associated with the form control it relates to using <code>aria-describedby</code>. Alternatively, ensure that the meaning (for instance, the fact that there is a warning for a particular text entry field) is conveyed in some other form, such as changing the text of the actual <code>&lt;label&gt;</code> associated with the form control.</p>
710     <p>Although the following examples already mention the validation state of their respective form controls in the <code>&lt;label&gt;</code> text itself, the above technique (using <code>.sr-only</code> text and <code>aria-describedby</code>) has been included for illustrative purposes.</p>
711   </div>
712   <div class="bs-example" data-example-id="form-validation-states-with-icons">
713     <form>
714       <div class="form-group has-success has-feedback">
715         <label class="control-label" for="inputSuccess2">Input with success</label>
716         <input type="text" class="form-control" id="inputSuccess2" aria-describedby="inputSuccess2Status">
717         <span class="glyphicon glyphicon-ok form-control-feedback" aria-hidden="true"></span>
718         <span id="inputSuccess2Status" class="sr-only">(success)</span>
719       </div>
720       <div class="form-group has-warning has-feedback">
721         <label class="control-label" for="inputWarning2">Input with warning</label>
722         <input type="text" class="form-control" id="inputWarning2" aria-describedby="inputWarning2Status">
723         <span class="glyphicon glyphicon-warning-sign form-control-feedback" aria-hidden="true"></span>
724         <span id="inputWarning2Status" class="sr-only">(warning)</span>
725       </div>
726       <div class="form-group has-error has-feedback">
727         <label class="control-label" for="inputError2">Input with error</label>
728         <input type="text" class="form-control" id="inputError2" aria-describedby="inputError2Status">
729         <span class="glyphicon glyphicon-remove form-control-feedback" aria-hidden="true"></span>
730         <span id="inputError2Status" class="sr-only">(error)</span>
731       </div>
732       <div class="form-group has-success has-feedback">
733         <label class="control-label" for="inputGroupSuccess1">Input group with success</label>
734         <div class="input-group">
735           <span class="input-group-addon">@</span>
736           <input type="text" class="form-control" id="inputGroupSuccess1" aria-describedby="inputGroupSuccess1Status">
737         </div>
738         <span class="glyphicon glyphicon-ok form-control-feedback" aria-hidden="true"></span>
739         <span id="inputGroupSuccess1Status" class="sr-only">(success)</span>
740       </div>
741     </form>
742   </div>
743 {% highlight html %}
744 <div class="form-group has-success has-feedback">
745   <label class="control-label" for="inputSuccess2">Input with success</label>
746   <input type="text" class="form-control" id="inputSuccess2" aria-describedby="inputSuccess2Status">
747   <span class="glyphicon glyphicon-ok form-control-feedback" aria-hidden="true"></span>
748   <span id="inputSuccess2Status" class="sr-only">(success)</span>
749 </div>
750 <div class="form-group has-warning has-feedback">
751   <label class="control-label" for="inputWarning2">Input with warning</label>
752   <input type="text" class="form-control" id="inputWarning2" aria-describedby="inputWarning2Status">
753   <span class="glyphicon glyphicon-warning-sign form-control-feedback" aria-hidden="true"></span>
754   <span id="inputWarning2Status" class="sr-only">(warning)</span>
755 </div>
756 <div class="form-group has-error has-feedback">
757   <label class="control-label" for="inputError2">Input with error</label>
758   <input type="text" class="form-control" id="inputError2" aria-describedby="inputError2Status">
759   <span class="glyphicon glyphicon-remove form-control-feedback" aria-hidden="true"></span>
760   <span id="inputError2Status" class="sr-only">(error)</span>
761 </div>
762 <div class="form-group has-success has-feedback">
763   <label class="control-label" for="inputGroupSuccess1">Input group with success</label>
764   <div class="input-group">
765     <span class="input-group-addon">@</span>
766     <input type="text" class="form-control" id="inputGroupSuccess1" aria-describedby="inputGroupSuccess1Status">
767   </div>
768   <span class="glyphicon glyphicon-ok form-control-feedback" aria-hidden="true"></span>
769   <span id="inputGroupSuccess1Status" class="sr-only">(success)</span>
770 </div>
771 {% endhighlight %}
772
773   <h4>Optional icons in horizontal and inline forms</h4>
774   <div class="bs-example" data-example-id="horizontal-form-validation-state-with-icon">
775     <form class="form-horizontal">
776       <div class="form-group has-success has-feedback">
777         <label class="control-label col-sm-3" for="inputSuccess3">Input with success</label>
778         <div class="col-sm-9">
779           <input type="text" class="form-control" id="inputSuccess3" aria-describedby="inputSuccess3Status">
780           <span class="glyphicon glyphicon-ok form-control-feedback" aria-hidden="true"></span>
781           <span id="inputSuccess3Status" class="sr-only">(success)</span>
782         </div>
783       </div>
784       <div class="form-group has-success has-feedback">
785         <label class="control-label col-sm-3" for="inputGroupSuccess2">Input group with success</label>
786         <div class="col-sm-9">
787           <div class="input-group">
788             <span class="input-group-addon">@</span>
789             <input type="text" class="form-control" id="inputGroupSuccess2" aria-describedby="inputGroupSuccess2Status">
790           </div>
791           <span class="glyphicon glyphicon-ok form-control-feedback" aria-hidden="true"></span>
792           <span id="inputGroupSuccess2Status" class="sr-only">(success)</span>
793         </div>
794       </div>
795     </form>
796   </div>
797 {% highlight html %}
798 <form class="form-horizontal">
799   <div class="form-group has-success has-feedback">
800     <label class="control-label col-sm-3" for="inputSuccess3">Input with success</label>
801     <div class="col-sm-9">
802       <input type="text" class="form-control" id="inputSuccess3" aria-describedby="inputSuccess3Status">
803       <span class="glyphicon glyphicon-ok form-control-feedback" aria-hidden="true"></span>
804       <span id="inputSuccess3Status" class="sr-only">(success)</span>
805     </div>
806   </div>
807   <div class="form-group has-success has-feedback">
808     <label class="control-label col-sm-3" for="inputGroupSuccess2">Input group with success</label>
809     <div class="col-sm-9">
810       <div class="input-group">
811         <span class="input-group-addon">@</span>
812         <input type="text" class="form-control" id="inputGroupSuccess2" aria-describedby="inputGroupSuccess2Status">
813       </div>
814       <span class="glyphicon glyphicon-ok form-control-feedback" aria-hidden="true"></span>
815       <span id="inputGroupSuccess2Status" class="sr-only">(success)</span>
816     </div>
817   </div>
818 </form>
819 {% endhighlight %}
820
821   <div class="bs-example" data-example-id="inline-form-validation-state-with-icon">
822     <form class="form-inline">
823       <div class="form-group has-success has-feedback">
824         <label class="control-label" for="inputSuccess4">Input with success</label>
825         <input type="text" class="form-control" id="inputSuccess4" aria-describedby="inputSuccess4Status">
826         <span class="glyphicon glyphicon-ok form-control-feedback" aria-hidden="true"></span>
827         <span id="inputSuccess4Status" class="sr-only">(success)</span>
828       </div>
829     </form>
830     <br>
831     <form class="form-inline">
832       <div class="form-group has-success has-feedback">
833         <label class="control-label" for="inputGroupSuccess3">Input group with success</label>
834         <div class="input-group">
835           <span class="input-group-addon">@</span>
836           <input type="text" class="form-control" id="inputGroupSuccess3" aria-describedby="inputGroupSuccess3Status">
837         </div>
838         <span class="glyphicon glyphicon-ok form-control-feedback" aria-hidden="true"></span>
839         <span id="inputGroupSuccess3Status" class="sr-only">(success)</span>
840       </div>
841     </form>
842   </div>
843 {% highlight html %}
844 <form class="form-inline">
845   <div class="form-group has-success has-feedback">
846     <label class="control-label" for="inputSuccess4">Input with success</label>
847     <input type="text" class="form-control" id="inputSuccess4" aria-describedby="inputSuccess4Status">
848     <span class="glyphicon glyphicon-ok form-control-feedback" aria-hidden="true"></span>
849     <span id="inputSuccess4Status" class="sr-only">(success)</span>
850   </div>
851 </form>
852 <form class="form-inline">
853   <div class="form-group has-success has-feedback">
854     <label class="control-label" for="inputGroupSuccess3">Input group with success</label>
855     <div class="input-group">
856       <span class="input-group-addon">@</span>
857       <input type="text" class="form-control" id="inputGroupSuccess3" aria-describedby="inputGroupSuccess3Status">
858     </div>
859     <span class="glyphicon glyphicon-ok form-control-feedback" aria-hidden="true"></span>
860     <span id="inputGroupSuccess3Status" class="sr-only">(success)</span>
861   </div>
862 </form>
863 {% endhighlight %}
864
865   <h4>Optional icons with hidden <code>.sr-only</code> labels</h4>
866   <p>If you use the <code>.sr-only</code> class to hide a form control's <code>&lt;label&gt;</code> (rather than using other labelling options, such as the <code>aria-label</code> attribute), Bootstrap will automatically adjust the position of the icon once it's been added.</p>
867   <div class="bs-example" data-example-id="form-validation-state-with-icon-without-label">
868     <div class="form-group has-success has-feedback">
869       <label class="control-label sr-only" for="inputSuccess5">Hidden label</label>
870       <input type="text" class="form-control" id="inputSuccess5" aria-describedby="inputSuccess5Status">
871       <span class="glyphicon glyphicon-ok form-control-feedback" aria-hidden="true"></span>
872       <span id="inputSuccess5Status" class="sr-only">(success)</span>
873     </div>
874     <div class="form-group has-success has-feedback">
875       <label class="control-label sr-only" for="inputGroupSuccess4">Input group with success</label>
876       <div class="input-group">
877         <span class="input-group-addon">@</span>
878         <input type="text" class="form-control" id="inputGroupSuccess4" aria-describedby="inputGroupSuccess4Status">
879       </div>
880       <span class="glyphicon glyphicon-ok form-control-feedback" aria-hidden="true"></span>
881       <span id="inputGroupSuccess4Status" class="sr-only">(success)</span>
882     </div>
883   </div>
884 {% highlight html %}
885 <div class="form-group has-success has-feedback">
886   <label class="control-label sr-only" for="inputSuccess5">Hidden label</label>
887   <input type="text" class="form-control" id="inputSuccess5" aria-describedby="inputSuccess5Status">
888   <span class="glyphicon glyphicon-ok form-control-feedback" aria-hidden="true"></span>
889   <span id="inputSuccess5Status" class="sr-only">(success)</span>
890 </div>
891 <div class="form-group has-success has-feedback">
892   <label class="control-label sr-only" for="inputGroupSuccess4">Input group with success</label>
893   <div class="input-group">
894     <span class="input-group-addon">@</span>
895     <input type="text" class="form-control" id="inputGroupSuccess4" aria-describedby="inputGroupSuccess4Status">
896   </div>
897   <span class="glyphicon glyphicon-ok form-control-feedback" aria-hidden="true"></span>
898   <span id="inputGroupSuccess4Status" class="sr-only">(success)</span>
899 </div>
900 {% endhighlight %}
901
902
903   <h2 id="forms-control-sizes">Control sizing</h2>
904   <p>Set heights using classes like <code>.input-lg</code>, and set widths using grid column classes like <code>.col-lg-*</code>.</p>
905
906   <h3>Height sizing</h3>
907   <p>Create taller or shorter form controls that match button sizes.</p>
908   <div class="bs-example bs-example-control-sizing" data-example-id="form-control-height-sizes">
909     <form>
910       <div class="controls">
911         <input class="form-control input-lg" type="text" placeholder=".input-lg">
912         <input type="text" class="form-control" placeholder="Default input">
913         <input class="form-control input-sm" type="text" placeholder=".input-sm">
914
915         <select class="form-control input-lg">
916           <option value="">.input-lg</option>
917         </select>
918         <select class="form-control">
919           <option value="">Default select</option>
920         </select>
921         <select class="form-control input-sm">
922           <option value="">.input-sm</option>
923         </select>
924       </div>
925     </form>
926   </div><!-- /.bs-example -->
927 {% highlight html %}
928 <input class="form-control input-lg" type="text" placeholder=".input-lg">
929 <input class="form-control" type="text" placeholder="Default input">
930 <input class="form-control input-sm" type="text" placeholder=".input-sm">
931
932 <select class="form-control input-lg">...</select>
933 <select class="form-control">...</select>
934 <select class="form-control input-sm">...</select>
935 {% endhighlight %}
936
937   <h3>Horizontal form group sizes</h3>
938   <p>Quickly size labels and form controls within <code>.form-horizontal</code> by adding <code>.form-group-lg</code> or <code>.form-group-sm</code>.</p>
939   <div class="bs-example" data-example-id="form-group-height-sizes">
940     <form class="form-horizontal">
941       <div class="form-group form-group-lg">
942         <label class="col-sm-2 control-label" for="formGroupInputLarge">Large label</label>
943         <div class="col-sm-10">
944           <input class="form-control" type="text" id="formGroupInputLarge" placeholder="Large input">
945         </div>
946       </div>
947       <div class="form-group form-group-sm">
948         <label class="col-sm-2 control-label" for="formGroupInputSmall">Small label</label>
949         <div class="col-sm-10">
950           <input class="form-control" type="text" id="formGroupInputSmall" placeholder="Small input">
951         </div>
952       </div>
953     </form>
954   </div><!-- /.bs-example -->
955 {% highlight html %}
956 <form class="form-horizontal">
957   <div class="form-group form-group-lg">
958     <label class="col-sm-2 control-label" for="formGroupInputLarge">Large label</label>
959     <div class="col-sm-10">
960       <input class="form-control" type="text" id="formGroupInputLarge" placeholder="Large input">
961     </div>
962   </div>
963   <div class="form-group form-group-sm">
964     <label class="col-sm-2 control-label" for="formGroupInputSmall">Small label</label>
965     <div class="col-sm-10">
966       <input class="form-control" type="text" id="formGroupInputSmall" placeholder="Small input">
967     </div>
968   </div>
969 </form>
970 {% endhighlight %}
971
972
973   <h3>Column sizing</h3>
974   <p>Wrap inputs in grid columns, or any custom parent element, to easily enforce desired widths.</p>
975   <div class="bs-example" data-example-id="form-control-column-sizing">
976     <form>
977       <div class="row">
978         <div class="col-xs-2">
979           <input type="text" class="form-control" placeholder=".col-xs-2">
980         </div>
981         <div class="col-xs-3">
982           <input type="text" class="form-control" placeholder=".col-xs-3">
983         </div>
984         <div class="col-xs-4">
985           <input type="text" class="form-control" placeholder=".col-xs-4">
986         </div>
987       </div>
988     </form>
989   </div><!-- /.bs-example -->
990 {% highlight html %}
991 <div class="row">
992   <div class="col-xs-2">
993     <input type="text" class="form-control" placeholder=".col-xs-2">
994   </div>
995   <div class="col-xs-3">
996     <input type="text" class="form-control" placeholder=".col-xs-3">
997   </div>
998   <div class="col-xs-4">
999     <input type="text" class="form-control" placeholder=".col-xs-4">
1000   </div>
1001 </div>
1002 {% endhighlight %}
1003
1004   <h2 id="forms-help-text">Help text</h2>
1005   <p>Block level help text for form controls.</p>
1006   <div class="bs-callout bs-callout-info" id="callout-help-text-accessibility">
1007     <h4>Associating help text with form controls</h4>
1008     <p>Help text should be explicitly associated with the form control it relates to using the <code>aria-describedby</code> attribute. This will ensure that assistive technologies – such as screen readers – will announce this help text when the user focuses or enters the control.</p>
1009   </div>
1010   <div class="bs-example" data-example-id="simple-help-text">
1011     <form>
1012       <div class="form-group">
1013         <label for="inputHelpBlock">Input with help text</label>
1014         <input type="text" id="inputHelpBlock" class="form-control" aria-describedby="helpBlock">
1015       </div>
1016       <span id="helpBlock" class="help-block">A block of help text that breaks onto a new line and may extend beyond one line.</span>
1017     </form>
1018   </div><!-- /.bs-example -->
1019 {% highlight html %}
1020 <label class="sr-only" for="inputHelpBlock">Input with help text</label>
1021 <input type="text" id="inputHelpBlock" class="form-control" aria-describedby="helpBlock">
1022 ...
1023 <span id="helpBlock" class="help-block">A block of help text that breaks onto a new line and may extend beyond one line.</span>
1024 {% endhighlight %}
1025 </div>