Form control style hrang hrang, layout option hrang hrang, leh form chi hrang hrang siamna atana custom component hrang hrangte entirnan leh hman dan tur kaihhruaina.
A tlangpuiin
Bootstrap-a form controls hian kan Rebooted form styles te chu class hrang hrang nen a tizau a. Heng class te hi hmang la, browser leh device hrang hranga rendering mumal zawk neih theih nan an customized display-ah opt rawh.
Input control thar zawk email verification, number thlan leh a dangte hmang tangkai turin typeinput zawng zawngah (eg, emailemail address atan emaw , numerical information atan emaw) attribute dik tak hmang ngei ang che .number
Bootstrap form styles te entir nan entirnan awlsam tak kan rawn tarlang e. Class mamawh documentation, form layout leh thil dang tam tak hriat duh chuan chhiar chhunzawm zel ang che.
Form control te pawh a awm
Textual form controls— <input>s, <select>s, leh s ang chi—chu class <textarea>nen style a ni. .form-controlA chhungah hian general appearance, focus state, sizing leh a dangte atana style hrang hrang a awm bawk.
File input atan chuan for tih kha swap .form-controlrawh .form-control-file.
Sizing a ni
.form-control-lgClass leh tih ang chi hmangin heights set rawh .form-control-sm.
Chhiar tur chauh a ni
Input pakhatah boolean attribute dah la, readonlyinput value tihdanglam loh nan. Read-only inputs te chu a light zawkin a lang (disabled inputs ang bawkin), mahse standard cursor chu vawng reng rawh.
Chhiar tur chauh plain text
<input readonly>I form-a element awmte chu plain text anga style-a siam i duh chuan .form-control-plaintextclass hmangin default form field styling chu paih la, margin leh padding dik tak chu vawng reng rawh.
Range Input te pawh a awm
hmangin horizontal scroll theih range inputs chu set rawh .form-control-range.
Checkbox leh radio te pawh a awm bawk
Default checkbox leh radio te chu , input type pahnih tan class pakhat hmanga siam that a ni a .form-check, chu chuan an HTML element te layout leh behavior a ti tha a ni Checkbox hi list pakhata option pakhat emaw, a aia tam emaw thlan nan a ni a, radio erawh chu tam tak zinga option pakhat thlan nan a ni thung.
Disabled checkbox leh radio te hi a support a, mahse not-allowedparent hover-a cursor pek tur <label>chuan disabledattribute chu .form-check-input. Disabled attribute hian input dinhmun tarlanna atana pui turin lighter color a apply ang.
Checkbox leh radio hman te hi HTML hmanga form validation support turin siam a ni a, label tawi tak tak, awlsam taka hmuh theih a pe bawk. Chutiang a nih avang chuan kan <input>s leh <label>s te hi sibling element an ni a, an <input>within a <label>. idHei hi a verbose deuh deuh a for, a <input>leh <label>.
Default (stack tawh) a ni.
Default-ah chuan, checkbox leh radio engzat pawh unau inhnaih tak takte chu vertical-in an dah ang a, a remchan dan angin an inthlau ang .form-check.
Inline a ni
Horizontal row khata checkbox emaw radio emaw chu .form-check-inlinegroup .form-check.
Label awm lovin
Add .position-staticto inputs chhunga .form-checklabel text nei lo. Assistive technology-te tana label chi khat (entir nan, hman aria-label) la pe turin hre reng ang che.
Ruangam
Bootstrap hi a hman theih avangin display: blockleh width: 100%kan form control zawng zawngah te pawh a hman theih avangin form te chu default in vertical-in a stack ang. He layout hi per-form basis-a tihdanglam nan class dang pawh hman theih a ni.
Group hrang hrang siam rawh
Class hi .form-groupform-a structure engemaw zat dah belh dan awlsam ber a ni. Label, control, optional help text, leh form validation messaging te grouping dik taka dah theihna tur class flexible a pe a ni. By default it only applies , mahse a tul angin margin-bottomstyle dang a pick up thin. s, s, emaw element dang zawng zawng .form-inlinenen hmang rawh .<fieldset><div>
Form grid a awm
Kan grid class hmangin form complex zawk siam theih a ni. Hengte hi form layout hrang hrang, column tam tak, width hrang hrang, leh alignment option dang mamawhna atan hmang ang che.
Form row a awm
, kan standard grid row a danglamna a ni a, chu chuan default column gutters te chu tighter leh compact layouts atan a override thei .rowbawk ..form-row
Grid system hmang hian layout complex zawk siam theih a ni bawk.
Horizontal ang maia awm
Grid hmangin horizontal form siam la, .rowclass chu form group-ah dah la, class hmangin .col-*-*i label leh control-te zau zawng tarlang rawh. .col-form-labelI s ah pawh add ve ngei ang che <label>, chutiang chuan an associated form controls te nen vertically centered an nih theih nan.
A châng chuan, chu i mamawh alignment ṭha famkim siam tûr chuan margin emaw padding utilities emaw i hman a ngai mai thei. Entirnan, padding-topkan stacked radio inputs label chu kan paih a, chu chuan text baseline chu a align tha zawk ang.
Horizontal form label siam dan tur
A size dik taka zawm turin or .col-form-label-smto .col-form-label-lgyour <label>s or s hmang ngei ang che .<legend>.form-control-lg.form-control-sm
Column lian leh te
Entirna hmasa lama kan hmuh tawh ang khan kan grid system hmang hian .cola .rowemaw .form-row. An inkarah chuan available width chu inang tlangin an then ang. I column-te subset pakhat chu space tam emaw tlem emaw la turin i thlang thei bawk a, a bak .cols chuan a bak zawng chu a inang tlangin a then a, column class bikte ang chi te nen .col-7.
Auto-sizing a ni
A hnuaia entirnan hian flexbox utility hmangin a chhunga thu awmte chu vertical-in a center a , i column-te’n a mamawh ang zat chauh hmun an luah theih nan a thlak .cola ni. .col-autoKawng dangin sawi ila, column chu a chhunga thu awm dan azirin a size a insiam a ni.
Chumi hnuah chuan chu chu size-specific column class hmangin vawi khat i remix leh thei ang.
Class hmang hian .form-inlinelabel hrang hrang, form control leh button hrang hrangte chu horizontal row pakhatah a lang thei ang. Inline form chhunga form control te hi an default state aiin a danglam deuh hlek.
Controls chu display: flex, HTML white space eng pawh collapse a, spacing leh flexbox utilities hmanga alignment control pek theihna a ni.
Control leh input group te width: autochuan Bootstrap default chu override turin an dawng width: 100%thin .
Mobile device-a viewport tawi te account turin controls chu 576px aia tlem lo viewport-ah chauh inline-in a lang thin.
Form control hrang hrangte zau zawng leh alignment chu spacing utilities (a hnuaia tarlan ang hian) nen manual-in i address a ngai mai thei. A tawp berah chuan, form control tin nen a dah tel fo ang <label>che, screenreader ni lo tlawhtute laka thup a ngai a nih pawhin .sr-only.
Custom form control leh select te pawh a support bawk.
Label thup ai chuan a danglamna tur
Input tin atan label i dah tel loh chuan screen reader ang chi assistive technology te hian i form-ah harsatna an nei ang. .sr-onlyHeng inline form te tan hian class hmangin label te chu i thup thei ang . Assistive technology-te tana label pek dan dang dang a awm a, chu chu aria-label, aria-labelledbyemaw titleattribute te hi a ni. Chung zinga pakhat mah a awm loh chuan, assistive technology-te chuan placeholderattribute hman an hmang thei a, a awm a nih chuan, mahse placeholderlabeling method dangte aiah hman a tha lo tih hre reng ang che.
Ṭanpuina thuziak
Form-a block-level help text chu hmangin siam theih a ni .form-text( .help-blockhmanlai chuan v3-a tih thin) hmangin siam theih a ni. Inline help text hi inline HTML element eng pawh hmangin flesible takin implement theih a ni a, utility class .text-muted.
Help text chu form controls nena inzawm tir
aria-describedbyHelp text chu attribute hmanna nena inzawm form control nen chiang taka inzawm tur a ni. Hei hian assistive technology—screen reader ang chi—chuan he help text hi user-in control-a a focus emaw, a luh emaw hunah an puang chhuak ang.
Inputs hnuaia help text hi style theih a ni .form-text. He class hian display: blocka chunga inputs atanga inhlat awlsam zawk nan top margin thenkhat a huam a, a dah belh bawk.
I password chu character 8-20 vel a sei tur a ni a, letter leh number a awm tur a ni a, space, special character, emoji a awm tur a ni lo.
Inline text hian inline HTML element pangngai (a <small>, <span>, emaw thil dang emaw pawh nise) chu utility class tih loh chu engmah dang nei lovin a hmang thei a ni.
Rualbanlo form te
disabledInput pakhatah boolean attribute dah la, user interaction awm lo tur leh lighter zawka lang turin.
A chhunga control zawng zawng disable disabledturin attribute chu a ah dah rawh.<fieldset>
Caveat chu anchor hmangin a awm
Default-ah chuan browser-te chuan a chhunga native form control ( <input>, <select>leh <button>elements) zawng zawng <fieldset disabled>chu disabled angin an en ang a, keyboard leh mouse-a inzawmna pahnih a awm loh nan. Mahse, i form-ah <a ... class="btn btn-*">elements pawh a tel a nih chuan hengte hi style of pointer-events: none. Button-te tana disabled state chungchang section-a kan sawi tawh ang khan (leh a bik takin anchor element-te tana sub-section-ah) he CSS property hi standardized a la ni lo va, Internet Explorer 10-ah pawh a support kim lo va, keyboard hmangtute chu an awm theih loh nan a khap dawn lo heng link te hi focus emaw activate emaw thei. Chuvangin him taka awm tur chuan custom JavaScript hmangin chutiang link chu disable rawh.
Cross-browser hmanga hman theih a ni
disabledBootstrap hian browser zawng zawngah heng style te hi a hmang vek dawn laiin, Internet Explorer 11 leh a hnuai lam hian attribute hi a support kim lo a <fieldset>ni. Heng browser-a fieldset awmte hi tihtawp nan custom JavaScript hmang ang che.
Validation tih a ni
HTML5 form validation hmangin i hmangtute hnenah feedback hlu tak, actionable tak pe rawh– kan supported browser zawng zawngah hmuh theih a ni . Browser default validation feedback atang hian thlang la, a nih loh leh kan built-in class leh starter JavaScript hmangin custom message te implement rawh.
Tunah hian custom validation style hman kan rawt a, native browser default validation message-te chu browser zawng zawngah (a langsar ber chu desktop leh mobile-a Chrome)-ah assistive technology-ah a inhmang reng lo a ni.
A hnathawh dan
Bootstrap hmanga form validation hnathawh dan chu hetiang hi a ni:
HTML form validation hi CSS-a pseudo-classes pahnih hmangin hman a ni a, :invalidleh :valid. <input>, <select>, leh <textarea>element- ah te a hman theih .
Bootstrap hian :invalidleh :validstyles te chu parent .was-validatedclass ah a scope a, a tlangpuiin <form>. Chutiang a nih loh chuan value nei lo field mamawh apiang chu page load-ah a dik lo angin a lang. Chutiang chuan engtikah nge activate tur tih i thlang thei ang (a tlangpuiin form thehluh tum hnuah).
Form hmel reset tur chuan (entir nan, AJAX hmanga dynamic form submission a nih chuan), submission hnua again .was-validatedatang chuan class chu paih chhuak rawh.<form>
Fallback angin, .is-invalidleh class te chu server side validation.is-valid atan pseudo-classes aiah hman theih a ni . An mamawh lo a.was-validatedNu leh pa class
CSS hnathawh danah harsatna a awm avangin (tunah chuan) <label>DOM-a form control hmaa lo awm a chu custom JavaScript puihna tel lovin style kan hmang thei lo.
Tunlai browser zawng zawng hian constraint validation API , form controls validate nana JavaScript method hrang hrang an support a.
Feedback message-ah hian browser default (browser tin tan a danglam, CSS hmanga style theih loh) emaw, HTML leh CSS dang nena kan custom feedback style emaw a hmang thei bawk.
setCustomValidityJavaScript hmangin custom validity message i pe thei bawk.
Chu chu ngaihtuah chungin, kan custom form validation styles, optional server side classes, leh browser defaults te tana a hnuaia demos te hi ngaihtuah la.
Custom style hrang hrang a awm bawk
Custom Bootstrap form validation message atan chuan novalidateboolean attribute chu i <form>. Hei hian browser default feedback tooltips te chu a titawp a, mahse JavaScript-a form validation API te chu a la lut thei tho. A hnuaia form hi thehluh tum ang che; kan JavaScript chuan submit button chu a intercept ang a, feedback a relay ang che. Submit i tum hian i form controls-a :invalidand styles hman dan i hmu ang.:valid
Custom feedback style-ah chuan feedback inhrilh tawnna tha zawk neih theih nan custom color, border, focus style leh background icon te a hmang thin. Background icons for <select>s hi .custom-select, nen chauh a awm a, .form-control.
Browser a default a ni
Custom validation feedback message emaw, form behavior thlak danglam tur JavaScript ziah emaw duh lo em ni? All good, browser defaults te pawh i hmang thei bawk. A hnuaia form hi submit tum ang che. I browser leh OS a zirin feedback style danglam deuh deuh i hmu ang.
Heng feedback style te hi CSS hmanga style theih a nih loh laiin, JavaScript hmangin feedback text chu i siam danglam thei tho.
Server lam a ni
Client-side validation hman kan rawt a, mahse server-side validation i mamawh a nih chuan form field dik lo leh dik lo chu leh hmangin i tarlang thei .is-invalidang .is-valid. .invalid-feedbackHeng class te nen hian a support bawk tih hre reng ang che .
Element thlawptu te
Kan entirnan form te hian <input>a chunga native textual s te kan tarlang a, mahse form validation style te pawh <textarea>s leh custom form control te tan pawh a awm bawk.
Hmanraw hman dan tur
I form layout-in a phal chuan, styled tooltip-a validation feedback lantir turin class-te .{valid|invalid}-feedbackchu class-te nen i swap thei ang. Tooltip positioning atan .{valid|invalid}-tooltipnu leh pa nei ngei ngei tur a ni. position: relativeA hnuaia entirnan hian kan column class te hian hei hi an nei tawh a, mahse i project hian setup dang a mamawh mai thei.
Custom form siam a ni
Customization leh cross browser consistency tam zawk neih duh chuan kan completely custom form elements hmangin browser defaults te chu thlak rawh. Semantic leh accessible markup chungah an siam a, chuvangin default form control eng pawh atan solid replacement an ni.
Checkbox leh radio te pawh a awm bawk
Checkbox tin leh radio <input>leh <label>pairing tin chu <div>kan custom control siam turin a in wrapped a ni. Structural lamah chuan hei hi kan default ang chiah a .form-checkni .
Kan state ~zawng zawng tan sibling selector ( ) kan hmang a —like —kan custom form indicator chu dik taka style turin. Class nena kan inzawm chuan item tin text chu kan style thei bawk a, chu chu...<input>:checked.custom-control-label<input> 's state hmangin kan style thei bawk.
<input>Default chu kan thup a, kan opacityhmang a, .custom-control-labela aiah custom form indicator thar siam nan leh hmangin kan hmang ::beforebawk ::after. Vanduaithlak takin custom one kan siam thei lo from just the <input>because CSS'scontent hian chu element-ah chuan hna a thawk lo.
Checked state-ah chuan Open Iconic atanga base64 embedded SVG icons kan hmang thin . Hei hian browser leh device hrang hranga styling leh positioning control tha ber min pe a ni.
Checkbox hrang hrang a awm
Custom checkbox te pawhin :indeterminateJavaScript hmanga manual-a set a nih chuan pseudo class hi an hmang thei bawk (a tarlanna tur HTML attribute a awm lo).
jQuery i hmang a nih chuan hetiang thil hi a tawk tur a ni:
Radio hrang hrangah te
Inline a ni
Ramtuileilo
Custom checkbox leh radio te pawh tihtawp theih a ni bawk. disabledBoolean attribute chu add la, <input>custom indicator leh label description chu a style nghal vek ang.
Switches a awm
Switch pakhat hian custom checkbox markup a nei a, mahse .custom-switchclass hmangin toggle switch a render thin. disabledSwitch te pawhin attribute hi an support bawk .
Menu thlang rawh
Custom <select>menu te hian custom class chauh a mamawh a, .custom-selectcustom style te trigger nan. Custom styles hi 's initial appearance chauh a ni a , browser limitation vangin s a <select>siam danglam thei lo .<option>
Kan text input lian leh te nena inmil turin custom select te te leh lian atang pawhin i thlang thei bawk.
Attribute pawh a multiplesupport bawk:
sizeAttribute a nih angin :
Zau zawng
hmangin custom <input type="range">control siam rawh .custom-range. Track (background) leh thumb (value) te hi browser hrang hrangah a inang vek turin style an nei vek a. IE leh Firefox chauhvin hmasawnna hmuh theiha tarlanna atan thumb veilam emaw dinglam emaw atanga an track “filling” an support avangin tunah hian kan support lo.
minRange inputs hian leh max— 0leh , te tan implicit value an nei a 100. minand maxattribute hmangtute tan value thar i dah thei bawk.
Default-ah chuan range input chu integer value-ah “snap” a ni. Hei hi thlak danglam tur chuan stepvalue i tarlang thei bawk. A hnuaia entirnan hian step="0.5".
File browser a awm bawk
Custom file input animate nana plugin rawt: bs-custom-file-input , chu chu tuna kan docs-a kan hman mek chu a ni.
File input hi bunch zinga gnarly ber a ni a, functional Choose file... leh selected file name text hmanga hook up duh chuan JavaScript dang a mamawh bawk .
<input>Default file chu kan thup a opacity, chu ai chuan kan style zawk a <label>ni. Button chu a siam a, a position chu ::after. widthA tawp berah chuan a leh heighton the <input>for proper spacing for surrounding content kan declare a .
SCSS hmanga string te lehlin emaw customize emaw
:lang()Pseudo-class hmang hian “Browse” tih thuziak chu ṭawng danga lehlin theih a ni. $custom-file-textSass variable-ah hian a kaihhnawih language tag leh localized string hmangin entry override emaw add emaw theih a ni. English string pawh chutiang bawk chuan customize theih a ni. Entirnan, hetiang hian Spanish tawng lehlin a dah belh theih dan tur chu (Spanish tawng code chu es):
Spanish lang(es)tawnga lehlinna tur custom file input chungchangah hian action a awm a:
Text dik tak a lan theih nan i document (or a subtree) language chu dik taka i set a ngai ang. Hei hi element -a attribute langemaw HTTP header emaw hmangin tih theih a ni a , chu chu method dangte nen a ni.<html>Content-Language
HTML hmanga string te lehlin emaw, customize emaw
Bootstrap hian HTML-a “Browse” text chu data-browseattribute hmanga lehlin dan a pe bawk a, chu chu custom input label-ah dah theih a ni (entirnan Dutch tawngin):