Commit a68f73e7 authored by Patrick H. Lauke's avatar Patrick H. Lauke Committed by XhmikosR
Browse files

Remove unnecessary <form> elements, add a submit button to validation example

parent c96f6391
main cleanup-floating-forms cssvar-function dependabot/npm_and_yarn/stylelint-and-stylelint-config-twbs-bootstrap-15.3.0 extend-snippets feat/data-target floating-always-visible floating-labels-icons fod-main-banner form-controls-with-icons github/fork/719media/patch-13 github/fork/719media/patch-14 github/fork/719media/patch-9 github/fork/ChellyAhmed/fix-typo-reboot.md github/fork/ChellyAhmed/offcanvas-scroll-back github/fork/CtrlAltLilith/main github/fork/Elysiome/offcanvas-optional-window-resizing github/fork/JanSargsyan/main github/fork/LunicLynx/support-different-line-height-for-buttons github/fork/Psixodelik/main github/fork/Ronid1/ronid1/offcanvas_static_backdrop github/fork/RyanBerliner/tooltip-accessibility github/fork/SantiagoPVazquez/Feature-default-border-bottom-to-dropdown-item github/fork/Sir-Genius/utils github/fork/Sumit-Singh-8/main github/fork/Viktor-VERA2020/offcanvas-slide github/fork/Zivangu9/input-group-for-form-control-plaintext github/fork/alpadev/alpadev/call-dispose-on-component-reinstantiation github/fork/astagi/fix/tree-shake-modules github/fork/compnerd/dark-accordion-icon github/fork/derSascha/dropdown-dont-close-on-input-click github/fork/dev-ph1l/main github/fork/donquixote/issue-33861-utl-mixin github/fork/florianlacreuse/mixin-make-row-gutter-y github/fork/gregorw/main github/fork/iteggmbh/transitionend-dispose-race github/fork/jdelStrother/patch-1 github/fork/jonnysp/form-floating github/fork/jonnysp/independent-offcanvas github/fork/jonnysp/theme-dark-on-card-and-modal-fix github/fork/josefdlange/floating-label-placeholder-opacity github/fork/julien-deramond/enhance-change-version.js github/fork/julien-deramond/main-jd-fix-offset-content github/fork/julien-deramond/main-jd-issue-with-utitlies github/fork/julien-deramond/main-xmr-pa11y-ci-jd-add-hideElements github/fork/kyletsang/fix-tooltip-padding github/fork/lacutah/CheckboxCenteringDocumentation github/fork/lekoala/patch-3 github/fork/louismaximepiton/main-kld-lmp-collapse-proposal github/fork/louismaximepiton/main-lmp-card-inner-border-radius-fix github/fork/louismaximepiton/main-lmp-carousel-multiple-images github/fork/louismaximepiton/main-lmp-css-var-init github/fork/louismaximepiton/main-lmp-disabled-floating-label-fix github/fork/louismaximepiton/main-lmp-input-range-fix github/fork/louismaximepiton/main-lmp-shift-color github/fork/louismaximepiton/main-lmp-table-active-tr-fix github/fork/maciek-szn/switch github/fork/michael-roth/feature/19964-multiple-tab-targets github/fork/mistic100/dom-utils github/fork/nkdas91/accordion github/fork/nstungcom/fix-missing-modal-open-class github/fork/oraliahdz/animation-utilities github/fork/pine3ree/patch-7 github/fork/pouwerkerk/unindent-scss-docs-shortcode github/fork/smares/smares-no-scolling-on-modal-close github/fork/tgm-git/patch-1 gs-forms gs-toasts-with-animated-progress-bar gs/add-history-helper gs/change-version-dir-on-docs gs/data-must-set-onlu-one-instance gs/docs/fix-drop-down-error gs/event-handler-2 gs/make-docs-js-build gs/make-simple-attribute-toggler gs/popover-fix-doc gs/provide-steConfig-method gs/scrollspy-smoothscroll-option-use-browser-history gs/streamline-jqueryInterface gs/support-drop-down-in-navbar gs/test-js-generic-trigger gs/try-web-components gs/tweak-collapse-js-selector gs/use-event-handler-in-cocmponent gs/use-rollup-replace-for-version jo-docs-thanks-page jo-ssr-friendly logical-props-spacing-utils main-fod-disabled-form-check-label main-fod-nested-accordion main-fod-simpler-table-structure main-fod-table-separator main-fod-utilities-contrast main-jd-abbr-title main-jd-add-chips main-jd-add-doc-for-sass-custom-colors main-jd-add-enable-host-to-handle-web-components main-jd-browserstack-fine-tune main-jd-browserstack-updates main-jd-docs-consistent-usage-of-css-sections-step-2 main-jd-fix-docs-headers-in-white main-jd-fix-highlight-docs-border-radius main-jd-fix-placeholder-color-background-params-for-img-markup main-jd-glossary-experiment main-jd-postcss-drop-empty-css-vars main-jd-proto-doc-astro main-jd-skip-navigation-component main-jd-stackblitz-for-examples main-jd-upgrade-browserlistrc main-jd-use-host main-lmp-dark-theme-customization main-lmp-handle-scroll-target main-lmp-tab-fix main-mc-opensearch main-xmr-bundlewatch-action main-xmr-eslint-plugin-compat main-xmr-hugo-docs-vendor main-xmr-hugo-rm-ver main-xmr-linkinator-prod main-xmr-min-mangle main-xmr-pa11y-ci more-darkmode-examples nested-dropdowns patrickhlauke-issue37428 patrickhlauke-use-of-color-tweaks pr/34102 pr/37590 previous-next-docs-links sticky-thead utilities-functions-mixin v530-dev v6-postcss-custom-media v6-spinner-dots v6/gs/use-floating-ui-in-place-of-popper xmr/dev xmr/docs-png xmr/docs-svgs xmr/hugo-reorg-files xmr/js-2 xmr/markdownlint xmr/prepare-530-alpha2 xmr/xo v5.3.0-alpha1 v5.2.3 v5.2.2 v5.2.1 v5.2.0 v5.2.0-beta1 v5.1.3 v5.1.2 v5.1.1 v5.1.0 v5.0.2 v5.0.1 v5.0.0 v5.0.0-beta3 v5.0.0-beta2 v5.0.0-beta1 v5.0.0-alpha3 v5.0.0-alpha2 v5.0.0-alpha1
1 merge request!31948Examples/Floating-labels: fix bad behavior with autofill
Showing with 57 additions and 65 deletions
+57 -65
...@@ -9,16 +9,14 @@ toc: true ...@@ -9,16 +9,14 @@ toc: true
## Example ## Example
{{< example >}} {{< example >}}
<form> <div class="mb-3">
<div class="mb-3"> <label for="exampleFormControlInput1">Email address</label>
<label for="exampleFormControlInput1">Email address</label> <input type="email" class="form-control" id="exampleFormControlInput1" placeholder="name@example.com">
<input type="email" class="form-control" id="exampleFormControlInput1" placeholder="name@example.com"> </div>
</div> <div class="mb-3">
<div class="mb-3"> <label for="exampleFormControlTextarea1">Example textarea</label>
<label for="exampleFormControlTextarea1">Example textarea</label> <textarea class="form-control" id="exampleFormControlTextarea1" rows="3"></textarea>
<textarea class="form-control" id="exampleFormControlTextarea1" rows="3"></textarea> </div>
</div>
</form>
{{< /example >}} {{< /example >}}
## Sizing ## Sizing
...@@ -44,7 +42,6 @@ Add the `readonly` boolean attribute on an input to prevent modification of the ...@@ -44,7 +42,6 @@ Add the `readonly` boolean attribute on an input to prevent modification of the
If you want to have `<input readonly>` elements in your form styled as plain text, use the `.form-control-plaintext` class to remove the default form field styling and preserve the correct margin and padding. If you want to have `<input readonly>` elements in your form styled as plain text, use the `.form-control-plaintext` class to remove the default form field styling and preserve the correct margin and padding.
{{< example >}} {{< example >}}
<form>
<div class="mb-3 row"> <div class="mb-3 row">
<label for="staticEmail" class="col-sm-2 col-form-label">Email</label> <label for="staticEmail" class="col-sm-2 col-form-label">Email</label>
<div class="col-sm-10"> <div class="col-sm-10">
...@@ -57,7 +54,6 @@ If you want to have `<input readonly>` elements in your form styled as plain tex ...@@ -57,7 +54,6 @@ If you want to have `<input readonly>` elements in your form styled as plain tex
<input type="password" class="form-control" id="inputPassword"> <input type="password" class="form-control" id="inputPassword">
</div> </div>
</div> </div>
</form>
{{< /example >}} {{< /example >}}
{{< example >}} {{< example >}}
...@@ -79,10 +75,8 @@ If you want to have `<input readonly>` elements in your form styled as plain tex ...@@ -79,10 +75,8 @@ If you want to have `<input readonly>` elements in your form styled as plain tex
## Color ## Color
{{< example >}} {{< example >}}
<form> <label for="exampleColorInput">Color picker</label>
<label for="exampleColorInput">Color picker</label> <input type="color" class="form-control form-control-color" id="exampleColorInput" value="#563d7c" title="Choose your color">
<input type="color" class="form-control form-control-color" id="exampleColorInput" value="#563d7c" title="Choose your color">
</form>
{{< /example >}} {{< /example >}}
## Datalists ## Datalists
...@@ -92,15 +86,13 @@ Datalists allow you to create a group of `<option>`s that can be accessed (and a ...@@ -92,15 +86,13 @@ Datalists allow you to create a group of `<option>`s that can be accessed (and a
Learn more about [support for datalist elements](https://caniuse.com/#feat=datalist). Learn more about [support for datalist elements](https://caniuse.com/#feat=datalist).
{{< example >}} {{< example >}}
<form> <label for="exampleDataList">Datalist example</label>
<label for="exampleDataList">Datalist example</label> <input class="form-control" list="datalistOptions" id="exampleDataList" placeholder="Type to search...">
<input class="form-control" list="datalistOptions" id="exampleDataList" placeholder="Type to search..."> <datalist id="datalistOptions">
<datalist id="datalistOptions"> <option value="San Francisco">
<option value="San Francisco"> <option value="New York">
<option value="New York"> <option value="Seattle">
<option value="Seattle"> <option value="Los Angeles">
<option value="Los Angeles"> <option value="Chicago">
<option value="Chicago"> </datalist>
</datalist>
</form>
{{< /example >}} {{< /example >}}
...@@ -23,16 +23,14 @@ Since Bootstrap applies `display: block` and `width: 100%` to almost all our for ...@@ -23,16 +23,14 @@ Since Bootstrap applies `display: block` and `width: 100%` to almost all our for
Feel free to build your forms however you like, with `<fieldset>`s, `<div>`s, or nearly any other element. Feel free to build your forms however you like, with `<fieldset>`s, `<div>`s, or nearly any other element.
{{< example >}} {{< example >}}
<form> <div class="mb-3">
<div class="mb-3"> <label for="formGroupExampleInput">Example label</label>
<label for="formGroupExampleInput">Example label</label> <input type="text" class="form-control" id="formGroupExampleInput" placeholder="Example input placeholder">
<input type="text" class="form-control" id="formGroupExampleInput" placeholder="Example input placeholder"> </div>
</div> <div class="mb-3">
<div class="mb-3"> <label for="formGroupExampleInput2">Another label</label>
<label for="formGroupExampleInput2">Another label</label> <input type="text" class="form-control" id="formGroupExampleInput2" placeholder="Another input placeholder">
<input type="text" class="form-control" id="formGroupExampleInput2" placeholder="Another input placeholder"> </div>
</div>
</form>
{{< /example >}} {{< /example >}}
## Form grid ## Form grid
...@@ -40,14 +38,14 @@ Feel free to build your forms however you like, with `<fieldset>`s, `<div>`s, or ...@@ -40,14 +38,14 @@ Feel free to build your forms however you like, with `<fieldset>`s, `<div>`s, or
More complex forms can be built using our grid classes. Use these for form layouts that require multiple columns, varied widths, and additional alignment options. **Requires the `$enable-grid-classes` Sass variable to be enabled** (on by default). More complex forms can be built using our grid classes. Use these for form layouts that require multiple columns, varied widths, and additional alignment options. **Requires the `$enable-grid-classes` Sass variable to be enabled** (on by default).
{{< example >}} {{< example >}}
<form class="row"> <div class="row">
<div class="col"> <div class="col">
<input type="text" class="form-control" placeholder="First name"> <input type="text" class="form-control" placeholder="First name">
</div> </div>
<div class="col"> <div class="col">
<input type="text" class="form-control" placeholder="Last name"> <input type="text" class="form-control" placeholder="Last name">
</div> </div>
</form> </div>
{{< /example >}} {{< /example >}}
## Gutters ## Gutters
...@@ -55,14 +53,14 @@ More complex forms can be built using our grid classes. Use these for form layou ...@@ -55,14 +53,14 @@ More complex forms can be built using our grid classes. Use these for form layou
By adding [gutter modifier classes]({{< docsref "/layout/grid#gutters" >}}), you can have control over the gutter width in as well the inline as block direction. **Also requires the `$enable-grid-classes` Sass variable to be enabled** (on by default). By adding [gutter modifier classes]({{< docsref "/layout/grid#gutters" >}}), you can have control over the gutter width in as well the inline as block direction. **Also requires the `$enable-grid-classes` Sass variable to be enabled** (on by default).
{{< example >}} {{< example >}}
<form class="row g-3"> <div class="row g-3">
<div class="col"> <div class="col">
<input type="text" class="form-control" placeholder="First name"> <input type="text" class="form-control" placeholder="First name">
</div> </div>
<div class="col"> <div class="col">
<input type="text" class="form-control" placeholder="Last name"> <input type="text" class="form-control" placeholder="Last name">
</div> </div>
</form> </div>
{{< /example >}} {{< /example >}}
More complex layouts can also be created with the grid system. More complex layouts can also be created with the grid system.
...@@ -179,26 +177,24 @@ At times, you maybe need to use margin or padding utilities to create that perfe ...@@ -179,26 +177,24 @@ At times, you maybe need to use margin or padding utilities to create that perfe
Be sure to use `.col-form-label-sm` or `.col-form-label-lg` to your `<label>`s or `<legend>`s to correctly follow the size of `.form-control-lg` and `.form-control-sm`. Be sure to use `.col-form-label-sm` or `.col-form-label-lg` to your `<label>`s or `<legend>`s to correctly follow the size of `.form-control-lg` and `.form-control-sm`.
{{< example >}} {{< example >}}
<form> <div class="row mb-3">
<div class="row mb-3"> <label for="colFormLabelSm" class="col-sm-2 col-form-label col-form-label-sm">Email</label>
<label for="colFormLabelSm" class="col-sm-2 col-form-label col-form-label-sm">Email</label> <div class="col-sm-10">
<div class="col-sm-10"> <input type="email" class="form-control form-control-sm" id="colFormLabelSm" placeholder="col-form-label-sm">
<input type="email" class="form-control form-control-sm" id="colFormLabelSm" placeholder="col-form-label-sm"> </div>
</div> </div>
</div> <div class="row mb-3">
<div class="row mb-3"> <label for="colFormLabel" class="col-sm-2 col-form-label">Email</label>
<label for="colFormLabel" class="col-sm-2 col-form-label">Email</label> <div class="col-sm-10">
<div class="col-sm-10"> <input type="email" class="form-control" id="colFormLabel" placeholder="col-form-label">
<input type="email" class="form-control" id="colFormLabel" placeholder="col-form-label"> </div>
</div> </div>
</div> <div class="row">
<div class="row"> <label for="colFormLabelLg" class="col-sm-2 col-form-label col-form-label-lg">Email</label>
<label for="colFormLabelLg" class="col-sm-2 col-form-label col-form-label-lg">Email</label> <div class="col-sm-10">
<div class="col-sm-10"> <input type="email" class="form-control form-control-lg" id="colFormLabelLg" placeholder="col-form-label-lg">
<input type="email" class="form-control form-control-lg" id="colFormLabelLg" placeholder="col-form-label-lg"> </div>
</div> </div>
</div>
</form>
{{< /example >}} {{< /example >}}
## Column sizing ## Column sizing
...@@ -206,7 +202,7 @@ Be sure to use `.col-form-label-sm` or `.col-form-label-lg` to your `<label>`s o ...@@ -206,7 +202,7 @@ Be sure to use `.col-form-label-sm` or `.col-form-label-lg` to your `<label>`s o
As shown in the previous examples, our grid system allows you to place any number of `.col`s within a `.row`. They'll split the available width equally between them. You may also pick a subset of your columns to take up more or less space, while the remaining `.col`s equally split the rest, with specific column classes like `.col-sm-7`. As shown in the previous examples, our grid system allows you to place any number of `.col`s within a `.row`. They'll split the available width equally between them. You may also pick a subset of your columns to take up more or less space, while the remaining `.col`s equally split the rest, with specific column classes like `.col-sm-7`.
{{< example >}} {{< example >}}
<form class="row g-3"> <div class="row g-3">
<div class="col-sm-7"> <div class="col-sm-7">
<input type="text" class="form-control" placeholder="City"> <input type="text" class="form-control" placeholder="City">
</div> </div>
...@@ -216,7 +212,7 @@ As shown in the previous examples, our grid system allows you to place any numbe ...@@ -216,7 +212,7 @@ As shown in the previous examples, our grid system allows you to place any numbe
<div class="col-sm"> <div class="col-sm">
<input type="text" class="form-control" placeholder="Zip"> <input type="text" class="form-control" placeholder="Zip">
</div> </div>
</form> </div>
{{< /example >}} {{< /example >}}
## Auto-sizing ## Auto-sizing
......
...@@ -74,7 +74,7 @@ Help text below inputs can be styled with `.form-text`. This class includes `dis ...@@ -74,7 +74,7 @@ Help text below inputs can be styled with `.form-text`. This class includes `dis
Inline text can use any typical inline HTML element (be it a `<small>`, `<span>`, or something else) with nothing more than a utility class. Inline text can use any typical inline HTML element (be it a `<small>`, `<span>`, or something else) with nothing more than a utility class.
{{< example >}} {{< example >}}
<form class="row g-3 align-items-center"> <div class="row g-3 align-items-center">
<div class="col-auto"> <div class="col-auto">
<label for="inputPassword6" class="col-form-label">Password</label> <label for="inputPassword6" class="col-form-label">Password</label>
</div> </div>
...@@ -86,7 +86,7 @@ Inline text can use any typical inline HTML element (be it a `<small>`, `<span>` ...@@ -86,7 +86,7 @@ Inline text can use any typical inline HTML element (be it a `<small>`, `<span>`
Must be 8-20 characters long. Must be 8-20 characters long.
</small> </small>
</div> </div>
</form> </div>
{{< /example >}} {{< /example >}}
## Disabled forms ## Disabled forms
......
...@@ -297,6 +297,10 @@ Validation styles are available for the following form controls and components: ...@@ -297,6 +297,10 @@ Validation styles are available for the following form controls and components:
</label> </label>
<div class="invalid-feedback">Example invalid form file feedback</div> <div class="invalid-feedback">Example invalid form file feedback</div>
</div> </div>
<div class="mb-3">
<button class="btn btn-primary" type="submit" disabled>Submit form</button>
</div>
</form> </form>
{{< /example >}} {{< /example >}}
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment