Diforomo
Mehlala le ditlhahlo ta tirio ta mekgwa ya taolo ya foromo, dikgetho ta peakanyo, le dikarolo ta tlwaelo ta go hlama mehutahuta ya diforomo.
Kakaretšo
Ditaolo tša foromo tša Bootstrap di atološa go mekgwa ya rena ya foromo ya Rebooted ka diklase. Šomiša diklase tše go kgetha go tsena dipontšhong tša tšona tše di rulagantšwego bakeng sa phetolelo ye e sa fetogego kudu go ralala le diphensele le didirišwa.
Kgonthiša gore o šomiša type
seka sa maleba go ditseno ka moka (mohlala, email
bakeng sa aterese ya imeile goba number
bakeng sa tshedimošo ya dipalo) go diriša mohola wa ditaolo tše mpsha tša tsenyo go swana le netefatšo ya imeile, kgetho ya dinomoro, le tše dingwe.
Mohlala wa ka pela wa go bontšha mekgwa ya foromo ya Bootstrap ke ye. Tšwela pele o bala bakeng sa ditokomane tša diklase tše di nyakegago, peakanyo ya foromo, le tše dingwe.
<form>
<div class="form-group">
<label for="exampleInputEmail1">Email address</label>
<input type="email" class="form-control" id="exampleInputEmail1" aria-describedby="emailHelp">
<small id="emailHelp" class="form-text text-muted">We'll never share your email with anyone else.</small>
</div>
<div class="form-group">
<label for="exampleInputPassword1">Password</label>
<input type="password" class="form-control" id="exampleInputPassword1">
</div>
<div class="form-group form-check">
<input type="checkbox" class="form-check-input" id="exampleCheck1">
<label class="form-check-label" for="exampleCheck1">Check me out</label>
</div>
<button type="submit" class="btn btn-primary">Submit</button>
</form>
Ditaolo tša foromo
Ditaolo tša sebopego sa sengwalwa—go swana le <input>
s, <select>
s le <textarea>
s—di setaele le .form-control
sehlopha. Go akaretšwa mekgwa ya ponagalo ya kakaretšo, boemo bja go tsepamiša kgopolo, go lekanyetša bogolo le tše dingwe.
Kgonthiša gore o hlahloba diforomo tša rena tša tlwaelo go tšwetša pele setaele <select>
s.
<form>
<div class="form-group">
<label for="exampleFormControlInput1">Email address</label>
<input type="email" class="form-control" id="exampleFormControlInput1" placeholder="[email protected]">
</div>
<div class="form-group">
<label for="exampleFormControlSelect1">Example select</label>
<select class="form-control" id="exampleFormControlSelect1">
<option>1</option>
<option>2</option>
<option>3</option>
<option>4</option>
<option>5</option>
</select>
</div>
<div class="form-group">
<label for="exampleFormControlSelect2">Example multiple select</label>
<select multiple class="form-control" id="exampleFormControlSelect2">
<option>1</option>
<option>2</option>
<option>3</option>
<option>4</option>
<option>5</option>
</select>
</div>
<div class="form-group">
<label for="exampleFormControlTextarea1">Example textarea</label>
<textarea class="form-control" id="exampleFormControlTextarea1" rows="3"></textarea>
</div>
</form>
Bakeng sa ditshenyegelo tša faele, fapantšha .form-control
bakeng sa .form-control-file
.
<form>
<div class="form-group">
<label for="exampleFormControlFile1">Example file input</label>
<input type="file" class="form-control-file" id="exampleFormControlFile1">
</div>
</form>
Go lekanyetša bogolo
Beakanya bophagamo o šomiša diklase tša go swana .form-control-lg
le le .form-control-sm
.
<input class="form-control form-control-lg" type="text" placeholder=".form-control-lg">
<input class="form-control" type="text" placeholder="Default input">
<input class="form-control form-control-sm" type="text" placeholder=".form-control-sm">
<select class="form-control form-control-lg">
<option>Large select</option>
</select>
<select class="form-control">
<option>Default select</option>
</select>
<select class="form-control form-control-sm">
<option>Small select</option>
</select>
Bala feela
Oketša readonly
seka sa boolean go tsenyo go thibela phetošo ya boleng bja tsenyo. Ditseno tša go bala fela di bonala di le bofefo (go swana le ditseno tše di golofetšego), eupša boloka khesara ya maemo.
<input class="form-control" type="text" placeholder="Readonly input here..." readonly>
Sengwalwa se se tlwaelegilego fela
Ge o nyaka go ba le <input readonly>
dielemente ka foromong ya gago di setaele bjalo ka sengwalwa se se tlwaelegilego, omia .form-control-plaintext
sehlopha go tloa setaele sa tšhemo ya foromo ya maitirelo le go boloka moedi wa maleba le go tlatša.
<form>
<div class="form-group row">
<label for="staticEmail" class="col-sm-2 col-form-label">Email</label>
<div class="col-sm-10">
<input type="text" readonly class="form-control-plaintext" id="staticEmail" value="[email protected]">
</div>
</div>
<div class="form-group row">
<label for="inputPassword" class="col-sm-2 col-form-label">Password</label>
<div class="col-sm-10">
<input type="password" class="form-control" id="inputPassword">
</div>
</div>
</form>
<form class="form-inline">
<div class="form-group mb-2">
<label for="staticEmail2" class="sr-only">Email</label>
<input type="text" readonly class="form-control-plaintext" id="staticEmail2" value="[email protected]">
</div>
<div class="form-group mx-sm-3 mb-2">
<label for="inputPassword2" class="sr-only">Password</label>
<input type="password" class="form-control" id="inputPassword2" placeholder="Password">
</div>
<button type="submit" class="btn btn-primary mb-2">Confirm identity</button>
</form>
Ditseno tša Range
Beakanya ditshenyegelo tša legoro tšeo di ka kgokološwago ka go rapalala ka go šomiša .form-control-range
.
<form>
<div class="form-group">
<label for="formControlRange">Example Range input</label>
<input type="range" class="form-control-range" id="formControlRange">
</div>
</form>
Mapokisi a go hlahloba le diradio
Mapokisi a go hlahloba a maitirelo le diradio di kaonafatšwa ka thušo ya .form-check
, sehlopha se tee sa mehuta ka bobedi ya tsenyo yeo e kaonafatšago peakanyo le boitshwaro bja dielemente tša tšona tša HTML . Mapokisi a go hlahloba ke a go kgetha kgetho e tee goba tše mmalwa lenaneong, mola diradio e le tša go kgetha kgetho e tee go tšwa go tše dintši.
Mapokisi a go hlahloba ao a golofetšego le diradio di a thekgwa. Sebopego disabled
se tla diriša mmala wo bofefo go thuša go laetša boemo bja tsenyo.
Mapokisi a go hlahloba le dikonope tša radio di thekga netefatšo ya foromo ye e theilwego godimo ga HTML le go fa dileibole tše kopana, tše di fihlelelwago. Ka ge go le bjalo, <input>
s le <label>
s ya rena ke dielemente tša bana babo rena go fapana le an <input>
ka gare ga a <label>
. Se se na le mantšu a mantši go se nene ka ge o swanetše go laetša id
le for
dika go amana le <input>
le <label>
.
Default (e kgobokeditšwe) .
Ka go ikemela, palo le ge e le efe ya mapokisi a go hlahloba le diradio tšeo e lego ngwanešo wa kgaufsi di tla kgoboketšwa ka go otlologa gomme tša arolwa ka mo go swanetšego ka .form-check
.
<div class="form-check">
<input class="form-check-input" type="checkbox" value="" id="defaultCheck1">
<label class="form-check-label" for="defaultCheck1">
Default checkbox
</label>
</div>
<div class="form-check">
<input class="form-check-input" type="checkbox" value="" id="defaultCheck2" disabled>
<label class="form-check-label" for="defaultCheck2">
Disabled checkbox
</label>
</div>
<div class="form-check">
<input class="form-check-input" type="radio" name="exampleRadios" id="exampleRadios1" value="option1" checked>
<label class="form-check-label" for="exampleRadios1">
Default radio
</label>
</div>
<div class="form-check">
<input class="form-check-input" type="radio" name="exampleRadios" id="exampleRadios2" value="option2">
<label class="form-check-label" for="exampleRadios2">
Second default radio
</label>
</div>
<div class="form-check">
<input class="form-check-input" type="radio" name="exampleRadios" id="exampleRadios3" value="option3" disabled>
<label class="form-check-label" for="exampleRadios3">
Disabled radio
</label>
</div>
Ka gare ga mothaladi
Hlopha mapokisi a go hlahloba goba diradio mothalong o swanago wa go rapalala ka go tlaleletša .form-check-inline
go efe goba efe .form-check
.
<div class="form-check form-check-inline">
<input class="form-check-input" type="checkbox" id="inlineCheckbox1" value="option1">
<label class="form-check-label" for="inlineCheckbox1">1</label>
</div>
<div class="form-check form-check-inline">
<input class="form-check-input" type="checkbox" id="inlineCheckbox2" value="option2">
<label class="form-check-label" for="inlineCheckbox2">2</label>
</div>
<div class="form-check form-check-inline">
<input class="form-check-input" type="checkbox" id="inlineCheckbox3" value="option3" disabled>
<label class="form-check-label" for="inlineCheckbox3">3 (disabled)</label>
</div>
<div class="form-check form-check-inline">
<input class="form-check-input" type="radio" name="inlineRadioOptions" id="inlineRadio1" value="option1">
<label class="form-check-label" for="inlineRadio1">1</label>
</div>
<div class="form-check form-check-inline">
<input class="form-check-input" type="radio" name="inlineRadioOptions" id="inlineRadio2" value="option2">
<label class="form-check-label" for="inlineRadio2">2</label>
</div>
<div class="form-check form-check-inline">
<input class="form-check-input" type="radio" name="inlineRadioOptions" id="inlineRadio3" value="option3" disabled>
<label class="form-check-label" for="inlineRadio3">3 (disabled)</label>
</div>
Ntle le dileibole
Oketša .position-static
go ditseno ka gare ga .form-check
tšeo di se nago sengwalwa sa leina. Gopola go sa dutše o nea mohuta o itšego wa leina leo le fihlelelwago bakeng sa thekinolotši ya go thuša (mohlala, go diriša aria-label
).
<div class="form-check">
<input class="form-check-input position-static" type="checkbox" id="blankCheckbox" value="option1" aria-label="...">
</div>
<div class="form-check">
<input class="form-check-input position-static" type="radio" name="blankRadio" id="blankRadio1" value="option1" aria-label="...">
</div>
Tlhamego
Ka ge Bootstrap e šoma display: block
le width: 100%
go mo e nyakilego go ba ditaolo tša rena ka moka tša foromo, diforomo di tla ka go ikemela go kgoboketša thwii. Diklase tša tlaleletšo di ka šomišwa go fapantšha peakanyo ye motheong wa foromo ka e tee.
Bopa dihlopha
Tlelase .form-group
ke tsela ye bonolo ya go oketša sebopego se sengwe go diforomo. E fa sehlopha se se fetofetogago seo se hlohleletšago go hlopha ka tshwanelo ga dileibole, ditaolo, sengwalwa sa thušo sa boikgethelo, le melaetša ya netefatšo ya foromo. By default it only applies margin-bottom
, empa e lata mekhoa e eketsehileng ka .form-inline
e le ho hlokahala. E diriše le <fieldset>
s, <div>
s goba mo e nyakilego go ba elemente le ge e le efe e nngwe.
<form>
<div class="form-group">
<label for="formGroupExampleInput">Example label</label>
<input type="text" class="form-control" id="formGroupExampleInput" placeholder="Example input placeholder">
</div>
<div class="form-group">
<label for="formGroupExampleInput2">Another label</label>
<input type="text" class="form-control" id="formGroupExampleInput2" placeholder="Another input placeholder">
</div>
</form>
Foromo ya keriti
Diforomo tše di raraganego kudu di ka agwa ka go šomiša diklase tša rena tša keriti. Šomiša tše bakeng sa dipeakanyo tša foromo tšeo di nyakago dikholomo tše dintši, bophara bjo bo fapanego, le dikgetho tša tlaleletšo tša go logaganya.
<form>
<div class="row">
<div class="col">
<input type="text" class="form-control" placeholder="First name">
</div>
<div class="col">
<input type="text" class="form-control" placeholder="Last name">
</div>
</div>
</form>
Mothaladi wa foromo
O ka boela wa fapantšha .row
bakeng sa .form-row
, e lego phetogo ya mothaladi wa rena wa keriti wa maemo wo o tlošago diphaephe tša kholomo tša go se fetoge bakeng sa dipeakanyo tše di tiilego le tše di kopanego kudu.
<form>
<div class="form-row">
<div class="col">
<input type="text" class="form-control" placeholder="First name">
</div>
<div class="col">
<input type="text" class="form-control" placeholder="Last name">
</div>
</div>
</form>
Dipeakanyo tše di raraganego kudu le tšona di ka hlolwa ka tshepedišo ya keriti.
<form>
<div class="form-row">
<div class="form-group col-md-6">
<label for="inputEmail4">Email</label>
<input type="email" class="form-control" id="inputEmail4">
</div>
<div class="form-group col-md-6">
<label for="inputPassword4">Password</label>
<input type="password" class="form-control" id="inputPassword4">
</div>
</div>
<div class="form-group">
<label for="inputAddress">Address</label>
<input type="text" class="form-control" id="inputAddress" placeholder="1234 Main St">
</div>
<div class="form-group">
<label for="inputAddress2">Address 2</label>
<input type="text" class="form-control" id="inputAddress2" placeholder="Apartment, studio, or floor">
</div>
<div class="form-row">
<div class="form-group col-md-6">
<label for="inputCity">City</label>
<input type="text" class="form-control" id="inputCity">
</div>
<div class="form-group col-md-4">
<label for="inputState">State</label>
<select id="inputState" class="form-control">
<option selected>Choose...</option>
<option>...</option>
</select>
</div>
<div class="form-group col-md-2">
<label for="inputZip">Zip</label>
<input type="text" class="form-control" id="inputZip">
</div>
</div>
<div class="form-group">
<div class="form-check">
<input class="form-check-input" type="checkbox" id="gridCheck">
<label class="form-check-label" for="gridCheck">
Check me out
</label>
</div>
</div>
<button type="submit" class="btn btn-primary">Sign in</button>
</form>
Foromo e rapameng
Hlama diforomo ta go rapalala ka keriti ka go tlaleleta .row
sehlopha go bopa dihlopha le go omia .col-*-*
diklase go laeta bophara bja dileibole ta gago le ditaolo. Kgonthiša gore o tlaleletša .col-form-label
go s ya gago <label>
gape gore di tsepame thwii ka ditaolo tša tšona tša foromo tše di sepedišanago le tšona.
Ka dinako tše dingwe, mo gongwe o swanetše go diriša didirišwa tša ka thoko goba tša go tlatša go bopa go logaganya moo mo go phethagetšego mo o go nyakago. Go fa mohlala, re tlošitše padding-top
leibole ya rena ya ditseno tša radio tše di kgobokeditšwego go logaganya motheo wa sengwalwa gakaone.
<form>
<div class="form-group row">
<label for="inputEmail3" class="col-sm-2 col-form-label">Email</label>
<div class="col-sm-10">
<input type="email" class="form-control" id="inputEmail3">
</div>
</div>
<div class="form-group row">
<label for="inputPassword3" class="col-sm-2 col-form-label">Password</label>
<div class="col-sm-10">
<input type="password" class="form-control" id="inputPassword3">
</div>
</div>
<fieldset class="form-group row">
<legend class="col-form-label col-sm-2 float-sm-left pt-0">Radios</legend>
<div class="col-sm-10">
<div class="form-check">
<input class="form-check-input" type="radio" name="gridRadios" id="gridRadios1" value="option1" checked>
<label class="form-check-label" for="gridRadios1">
First radio
</label>
</div>
<div class="form-check">
<input class="form-check-input" type="radio" name="gridRadios" id="gridRadios2" value="option2">
<label class="form-check-label" for="gridRadios2">
Second radio
</label>
</div>
<div class="form-check disabled">
<input class="form-check-input" type="radio" name="gridRadios" id="gridRadios3" value="option3" disabled>
<label class="form-check-label" for="gridRadios3">
Third disabled radio
</label>
</div>
</div>
</fieldset>
<div class="form-group row">
<div class="col-sm-10 offset-sm-2">
<div class="form-check">
<input class="form-check-input" type="checkbox" id="gridCheck1">
<label class="form-check-label" for="gridCheck1">
Example checkbox
</label>
</div>
</div>
</div>
<div class="form-group row">
<div class="col-sm-10">
<button type="submit" class="btn btn-primary">Sign in</button>
</div>
</div>
</form>
Horizontal foromo leibole sizing
Kgonthiša gore o šomiša .col-form-label-sm
goba .col-form-label-lg
go <label>
s goba s ya gago <legend>
go latela ka nepagalo bogolo bja .form-control-lg
le .form-control-sm
.
<form>
<div class="form-group row">
<label for="colFormLabelSm" class="col-sm-2 col-form-label col-form-label-sm">Email</label>
<div class="col-sm-10">
<input type="email" class="form-control form-control-sm" id="colFormLabelSm" placeholder="col-form-label-sm">
</div>
</div>
<div class="form-group row">
<label for="colFormLabel" class="col-sm-2 col-form-label">Email</label>
<div class="col-sm-10">
<input type="email" class="form-control" id="colFormLabel" placeholder="col-form-label">
</div>
</div>
<div class="form-group row">
<label for="colFormLabelLg" class="col-sm-2 col-form-label col-form-label-lg">Email</label>
<div class="col-sm-10">
<input type="email" class="form-control form-control-lg" id="colFormLabelLg" placeholder="col-form-label-lg">
</div>
</div>
</form>
Go lekanyetša bogolo bja kholomo
Bjalo ka ge go bontšhitšwe mehlaleng ye e fetilego, tshepedišo ya rena ya keriti e go dumelela go bea palo efe goba efe ya .col
s ka gare ga .row
goba .form-row
. Ba tla arola bophara bjo bo lego gona ka go lekana magareng ga bona. O ka kgetha gape sehlopha se senyenyane sa dikholomo tša gago go tšea sekgoba se segolo goba se senyenyane, mola .col
s ye e šetšego e aroganya tše dingwe ka go lekana, ka diklase tša dikholomo tše di itšego tša go swana le .col-7
.
<form>
<div class="form-row">
<div class="col-7">
<input type="text" class="form-control" placeholder="City">
</div>
<div class="col">
<input type="text" class="form-control" placeholder="State">
</div>
<div class="col">
<input type="text" class="form-control" placeholder="Zip">
</div>
</div>
</form>
Go dira bogolo bja go itiriša
Mohlala wo o lego ka mo tlase o šomiša sedirišwa sa flexbox go tsepamiša dikagare ka go otlologa le diphetogo .col
go .col-auto
gore dikholomo tša gago di tšee fela sekgoba se segolo ka moo go nyakegago. Ge re bea ka tsela ye nngwe, kholomo e itšeela bogolo go ya ka dikagare.
<form>
<div class="form-row align-items-center">
<div class="col-auto">
<label class="sr-only" for="inlineFormInput">Name</label>
<input type="text" class="form-control mb-2" id="inlineFormInput" placeholder="Jane Doe">
</div>
<div class="col-auto">
<label class="sr-only" for="inlineFormInputGroup">Username</label>
<div class="input-group mb-2">
<div class="input-group-prepend">
<div class="input-group-text">@</div>
</div>
<input type="text" class="form-control" id="inlineFormInputGroup" placeholder="Username">
</div>
</div>
<div class="col-auto">
<div class="form-check mb-2">
<input class="form-check-input" type="checkbox" id="autoSizingCheck">
<label class="form-check-label" for="autoSizingCheck">
Remember me
</label>
</div>
</div>
<div class="col-auto">
<button type="submit" class="btn btn-primary mb-2">Submit</button>
</div>
</div>
</form>
Ka morago o ka hlakanya seo gape gape ka diklase tša dikholomo tše di itšego tša bogolo.
<form>
<div class="form-row align-items-center">
<div class="col-sm-3 my-1">
<label class="sr-only" for="inlineFormInputName">Name</label>
<input type="text" class="form-control" id="inlineFormInputName" placeholder="Jane Doe">
</div>
<div class="col-sm-3 my-1">
<label class="sr-only" for="inlineFormInputGroupUsername">Username</label>
<div class="input-group">
<div class="input-group-prepend">
<div class="input-group-text">@</div>
</div>
<input type="text" class="form-control" id="inlineFormInputGroupUsername" placeholder="Username">
</div>
</div>
<div class="col-auto my-1">
<div class="form-check">
<input class="form-check-input" type="checkbox" id="autoSizingCheck2">
<label class="form-check-label" for="autoSizingCheck2">
Remember me
</label>
</div>
</div>
<div class="col-auto my-1">
<button type="submit" class="btn btn-primary">Submit</button>
</div>
</div>
</form>
Gomme go ba gona ditaolo tša foromo ya tlwaelo di a thekgwa.
<form>
<div class="form-row align-items-center">
<div class="col-auto my-1">
<label class="mr-sm-2 sr-only" for="inlineFormCustomSelect">Preference</label>
<select class="custom-select mr-sm-2" id="inlineFormCustomSelect">
<option selected>Choose...</option>
<option value="1">One</option>
<option value="2">Two</option>
<option value="3">Three</option>
</select>
</div>
<div class="col-auto my-1">
<div class="custom-control custom-checkbox mr-sm-2">
<input type="checkbox" class="custom-control-input" id="customControlAutosizing">
<label class="custom-control-label" for="customControlAutosizing">Remember my preference</label>
</div>
</div>
<div class="col-auto my-1">
<button type="submit" class="btn btn-primary">Submit</button>
</div>
</div>
</form>
Diforomo tša ka gare ga mothaladi
Šomiša .form-inline
sehlopha go bontšha lelokelelo la dileibole, ditaolo tša foromo, le dikonope mo moleng o tee wo o rapaletšego. Ditaolo tša foromo ka gare ga diforomo tša ka gare ga mothaladi di fapana gannyane go tšwa go maemo a tšona a go se fetoge.
- Ditaolo ke
display: flex
, go phuhlama sekgoba sefe goba sefe se sešweu sa HTML le go go dumelela go fa taolo ya go logaganya ka sekgoba le didirišwa tša flexbox . - Ditaolo le dihlopha tša tsenyo di amogela
width: auto
go tloša Bootstrap ya go se fetogewidth: 100%
. - Ditaolo di tšwelela fela ka gare ga mothaladi ka go dipono tša go lebelela tšeo di nago le bonyane bja 576px ka bophara go ikarabela ka dipono tše tshesane go didirišwa tša sellathekeng.
O ka swanelwa ke go rarolla ka seatla bophara le go logaganya ga ditaolo tša foromo ka botee ka didirišwa tša sekgoba (bjalo ka ge go bontšhitšwe ka mo tlase). Labofelo, kgonthišetša gore ka mehla o akaretša <label>
le taolo ya foromo e nngwe le e nngwe, gaešita le ge o swanetše go e uta go baeti bao e sego babadi ba skrine ka .sr-only
.
<form class="form-inline">
<label class="sr-only" for="inlineFormInputName2">Name</label>
<input type="text" class="form-control mb-2 mr-sm-2" id="inlineFormInputName2" placeholder="Jane Doe">
<label class="sr-only" for="inlineFormInputGroupUsername2">Username</label>
<div class="input-group mb-2 mr-sm-2">
<div class="input-group-prepend">
<div class="input-group-text">@</div>
</div>
<input type="text" class="form-control" id="inlineFormInputGroupUsername2" placeholder="Username">
</div>
<div class="form-check mb-2 mr-sm-2">
<input class="form-check-input" type="checkbox" id="inlineFormCheck">
<label class="form-check-label" for="inlineFormCheck">
Remember me
</label>
</div>
<button type="submit" class="btn btn-primary mb-2">Submit</button>
</form>
Ditaolo tša foromo ya tlwaelo le dikgetho le tšona di a thekgwa.
<form class="form-inline">
<label class="my-1 mr-2" for="inlineFormCustomSelectPref">Preference</label>
<select class="custom-select my-1 mr-sm-2" id="inlineFormCustomSelectPref">
<option selected>Choose...</option>
<option value="1">One</option>
<option value="2">Two</option>
<option value="3">Three</option>
</select>
<div class="custom-control custom-checkbox my-1 mr-sm-2">
<input type="checkbox" class="custom-control-input" id="customControlInline">
<label class="custom-control-label" for="customControlInline">Remember my preference</label>
</div>
<button type="submit" class="btn btn-primary my-1">Submit</button>
</form>
Dilo tše dingwe go e na le dileibole tše di utilwego
Dithekinolotši tša go thuša tša go swana le dibadi tša skrine di tla ba le bothata ka diforomo tša gago ge o sa akaretše leina la tsenyo ye nngwe le ye nngwe. Bakeng sa diforomo te ta ka gare ga mothaladi, o ka uta dileibole o omia .sr-only
sehlopha. Go na le mekgwa ye mengwe ye mengwe ya go fa leina la theknolotši ya go thuša, go swana le aria-label
, aria-labelledby
goba title
seka. Ge e le gore ga go le e tee ya tše yeo e lego gona, theknolotši ya go thuša e ka retologela go šomiša placeholder
seka, ge e le gona, eupša ela hloko gore tšhomišo ya placeholder
bjalo ka legato la mekgwa ye mengwe ya go swaya ga e eletšwe.
Sengwalwa sa thušo
Sengwalwa sa thušo sa maemo a boloko ka diforomong se ka hlolwa ka go šomiša .form-text
(yeo pele e bego e tsebja bjalo .help-block
ka go v3). Sengwalwa sa thušo sa ka gare ga mothaladi se ka phethagatšwa ka go fetofetoga ka go šomiša elemente efe goba efe ya HTML ya ka gare ga mothaladi le diklase tša mohola go swana le .text-muted
.
Go tswalanya sengwalwa sa thušo le ditaolo tša foromo
Sengwalwa sa thušo se swanetše go tswalanywa ka go lebanya le taolo ya foromo yeo e amanago le go šomiša aria-describedby
seka. Se se tla netefatša gore theknolotši ya go thuša—go swana le dibadi tša skrine—di tla tsebiša sengwalwa se sa thušo ge modiriši a tsepamiša kgopolo goba a tsena taolong.
Sengwalwa sa thušo ka fase ga ditseno se ka setaele ka .form-text
. Sehlopha se se akaretša display: block
le go tlaleletša ka thoko ye nngwe ya godimo bakeng sa sekgoba se bonolo go tšwa go ditseno tše di lego ka godimo.
<label for="inputPassword5">Password</label>
<input type="password" id="inputPassword5" class="form-control" aria-describedby="passwordHelpBlock">
<small id="passwordHelpBlock" class="form-text text-muted">
Your password must be 8-20 characters long, contain letters and numbers, and must not contain spaces, special characters, or emoji.
</small>
Sengwalwa sa ka gare ga mothaladi se ka šomiša elemente efe goba efe ye e tlwaelegilego ya HTML ya ka gare ga mothaladi (e ka ba <small>
, <span>
, goba se sengwe) seo se se nago selo go feta sehlopha sa mohola.
<form class="form-inline">
<div class="form-group">
<label for="inputPassword6">Password</label>
<input type="password" id="inputPassword6" class="form-control mx-sm-3" aria-describedby="passwordHelpInline">
<small id="passwordHelpInline" class="text-muted">
Must be 8-20 characters long.
</small>
</div>
</form>
Diforomo tša bao ba golofetšego
Oketša disabled
seka sa boolean go tsenyo go thibela ditirišano tša modiriši le go dira gore e bonagale e le bofefo.
<input class="form-control" id="disabledInput" type="text" placeholder="Disabled input here..." disabled>
Oketša disabled
seka go a <fieldset>
go šitiša ditaolo ka moka ka gare.
<form>
<fieldset disabled>
<legend>Disabled fieldset example</legend>
<div class="form-group">
<label for="disabledTextInput">Disabled input</label>
<input type="text" id="disabledTextInput" class="form-control" placeholder="Disabled input">
</div>
<div class="form-group">
<label for="disabledSelect">Disabled select menu</label>
<select id="disabledSelect" class="form-control">
<option>Disabled select</option>
</select>
</div>
<div class="form-group">
<div class="form-check">
<input class="form-check-input" type="checkbox" id="disabledFieldsetCheck" disabled>
<label class="form-check-label" for="disabledFieldsetCheck">
Can't check this
</label>
</div>
</div>
<button type="submit" class="btn btn-primary">Submit</button>
</fieldset>
</form>
Temošo ka ditshetledi
Diphensele di swara ditaolo ka moka tša foromo ya setlogo ( <input>
, <select>
, le <button>
dielemente) ka gare ga a <fieldset disabled>
bjalo ka tšeo di golofetšego, go thibela bobedi ditirišano tša khiiboto le toeba go tšona.
Le ge go le bjalo, ge e le gore foromo ya gago e akaretša gape le dielemente tša go swana le konope ya tlwaelo go swana le <a ... class="btn btn-*">
, tše di tla fiwa fela setaele sa pointer-events: none
. Bjalo ka ge go lemogilwe karolong ya mabapi le boemo bjo bo golofetšego bakeng sa dikonope (gomme ka go lebanya karolong ya ka tlase bakeng sa dielemente tša ankora), thepa ye ya CSS ga se ya hlwa e bewa maemong e bile ga se ya thekgwa ka botlalo go Internet Explorer 10. Ditaolo tšeo di theilwego go ankora le tšona di tla ba di sa dutše di le bjalo focusable le operable sebelisa khiboto. O swanetše go fetoša ka seatla ditaolo tše ka go tlaleletša tabindex="-1"
go di thibela go amogela nepo le aria-disabled="disabled"
go laetša boemo bja tšona go theknolotši ya go thuša.
Go sepelelana ga sefapano sa sephephediši
Le ge Bootstrap e tla diriša mekgwa ye go diphensele ka moka, Internet Explorer 11 le ka tlase ga e thekge ka botlalo disabled
seka go a <fieldset>
. Šomiša JavaScript ya tlwaelo go šitiša sete ya tšhemo go diphensele tše.
Netefatšo
Fana ka ditshwaelo tša bohlokwa, tše di ka tšeago kgato go badiriši ba gago ka netefatšo ya foromo ya HTML5– yeo e hwetšagalago go diphensele tša rena ka moka tšeo di thekgwago . Kgetha go tšwa go ditshwayotshwayo tša netefatšo ya go se fetoge ya sephephediši, goba phethagatša melaetša ya tlwaelo ka diklase tša rena tše di agetšwego ka gare le JavaScript ya go thoma.
Kamoo e šomago ka gona
Mona ke kamoo netefatšo ya foromo e šomago ka gona ka Bootstrap:
- Netefatšo ya foromo ya HTML e dirišwa ka dihlopha tše pedi tša maaka tša CSS,
:invalid
le:valid
. E šoma go<input>
,<select>
, le<textarea>
dielemente. - Bootstrap e akaretša
:invalid
le:valid
mekgwa go sehlopha sa motswadi.was-validated
, gantši e dirišwa go<form>
. Go sego bjalo, tšhemo efe goba efe ye e nyakegago ye e se nago boleng e bontšha bjalo ka yeo e sa šomego go laetša letlakala. Ka tsela ye, o ka kgetha gore o tla di tsenya tirišong neng (ka tlwaelo ka morago ga ge go lekile go romela foromo). - Go seta gape ponagalo ya foromo (mohlala, tabeng ya ditlhagišo tša foromo ye e fetogago ka go šomiša AJAX), tloša
.was-validated
sehlopha go tšwa go<form>
gape ka morago ga thomelo. - Bjalo ka fallback,
.is-invalid
gomme.is-valid
diklase di ka šomišwa go e na le diklase tša maaka bakeng sa netefatšo ya lehlakore la seva . Ga di nyake.was-validated
sehlopha sa motswadi. - Ka lebaka la dithibelo tša ka fao CSS e šomago ka gona, re ka se kgone (ga bjale) go diriša mekgwa go a
<label>
yeo e tlago pele ga taolo ya foromo ka go DOM ntle le thušo ya JavaScript ya tlwaelo. - Diphensele ka moka tša sebjalebjale di thekga API ya netefatšo ya thibelo , letoto la mekgwa ya JavaScript ya go netefatša ditaolo tša foromo.
- Melaetša ya ditshwayotshwayo e ka šomiša dilo tša go se fetoge tša sephephediši (tše di fapanego bakeng sa sephephediši se sengwe le se sengwe, le tšeo di sa setaelego ka CSS) goba mekgwa ya rena ya ditshwayotshwayo ya tlwaelo ka HTML le CSS ya tlaleletšo.
- O ka fana ka melaetša ya go nepagala ya tlwaelo ka
setCustomValidity
ka go JavaScript.
Ka seo ka kgopolong, nagana ka di-demo tše di latelago bakeng sa mekgwa ya rena ya go netefatša foromo ya tlwaelo, diklase tša lehlakore la seva tša boikhethelo, le dilo tša go se fetoge tša sephephediši.
Mekgwa ya tlwaelo
Bakeng sa melaetša ya netefatšo ya foromo ya Bootstrap ya tlwaelo, o tla swanelwa ke go oketša novalidate
seka sa boolean go ya gago <form>
. Se se šitiša didirišwa tša ditshwayotshwayo tša maitirelo tša sephephediši, eupša se sa fa phihlelelo go di-API tša netefatšo ya foromo ka go JavaScript. Leka go romela foromo ye e lego ka mo tlase; JavaScript ya rena e tla thibela konope ya go romela gomme ya go fetišetša ditshwayotshwayo. Ge o leka go romela, o tla bona :invalid
le :valid
ditaele di dirišitšwe go ditaolo tša gago tša foromo.
Mekgwa ya ditshwayotshwayo ya tlwaelo e diriša mebala ya tlwaelo, mellwane, mekgwa ya go tsepamiša kgopolo, le diaekhone tša ka morago go kgokaganya ditshwaotshwao gakaone. Diaekhone tša ka morago tša <select>
s di hwetšagala fela ka .custom-select
, e sego .form-control
.
<form class="needs-validation" novalidate>
<div class="form-row">
<div class="col-md-6 mb-3">
<label for="validationCustom01">First name</label>
<input type="text" class="form-control" id="validationCustom01" value="Mark" required>
<div class="valid-feedback">
Looks good!
</div>
</div>
<div class="col-md-6 mb-3">
<label for="validationCustom02">Last name</label>
<input type="text" class="form-control" id="validationCustom02" value="Otto" required>
<div class="valid-feedback">
Looks good!
</div>
</div>
</div>
<div class="form-row">
<div class="col-md-6 mb-3">
<label for="validationCustom03">City</label>
<input type="text" class="form-control" id="validationCustom03" required>
<div class="invalid-feedback">
Please provide a valid city.
</div>
</div>
<div class="col-md-3 mb-3">
<label for="validationCustom04">State</label>
<select class="custom-select" id="validationCustom04" required>
<option selected disabled value="">Choose...</option>
<option>...</option>
</select>
<div class="invalid-feedback">
Please select a valid state.
</div>
</div>
<div class="col-md-3 mb-3">
<label for="validationCustom05">Zip</label>
<input type="text" class="form-control" id="validationCustom05" required>
<div class="invalid-feedback">
Please provide a valid zip.
</div>
</div>
</div>
<div class="form-group">
<div class="form-check">
<input class="form-check-input" type="checkbox" value="" id="invalidCheck" required>
<label class="form-check-label" for="invalidCheck">
Agree to terms and conditions
</label>
<div class="invalid-feedback">
You must agree before submitting.
</div>
</div>
</div>
<button class="btn btn-primary" type="submit">Submit form</button>
</form>
<script>
// Example starter JavaScript for disabling form submissions if there are invalid fields
(function() {
'use strict';
window.addEventListener('load', function() {
// Fetch all the forms we want to apply custom Bootstrap validation styles to
var forms = document.getElementsByClassName('needs-validation');
// Loop over them and prevent submission
var validation = Array.prototype.filter.call(forms, function(form) {
form.addEventListener('submit', function(event) {
if (form.checkValidity() === false) {
event.preventDefault();
event.stopPropagation();
}
form.classList.add('was-validated');
}, false);
});
}, false);
})();
</script>
Di-default tša sephephediši
Ga o na kgahlego go melaetša ya ditshwayotshwayo tša netefatšo ya tlwaelo goba go ngwala JavaScript go fetoša maitshwaro a foromo? All molemo, o ka sebelisa sebadi defaults. Leka go romela foromo ye e lego ka mo tlase. Go ya ka sephephediši sa gago le OS, o tla bona setaele se se fapanego ganyenyane sa ditshwayotshwayo.
Le ge e le gore mekgwa ye ya ditshwaotshwao e ka se setaele ka CSS, o sa kgona go tlwaetša sengwalwa sa ditshwaotshwao ka JavaScript.
<form>
<div class="form-row">
<div class="col-md-6 mb-3">
<label for="validationDefault01">First name</label>
<input type="text" class="form-control" id="validationDefault01" value="Mark" required>
</div>
<div class="col-md-6 mb-3">
<label for="validationDefault02">Last name</label>
<input type="text" class="form-control" id="validationDefault02" value="Otto" required>
</div>
</div>
<div class="form-row">
<div class="col-md-6 mb-3">
<label for="validationDefault03">City</label>
<input type="text" class="form-control" id="validationDefault03" required>
</div>
<div class="col-md-3 mb-3">
<label for="validationDefault04">State</label>
<select class="custom-select" id="validationDefault04" required>
<option selected disabled value="">Choose...</option>
<option>...</option>
</select>
</div>
<div class="col-md-3 mb-3">
<label for="validationDefault05">Zip</label>
<input type="text" class="form-control" id="validationDefault05" required>
</div>
</div>
<div class="form-group">
<div class="form-check">
<input class="form-check-input" type="checkbox" value="" id="invalidCheck2" required>
<label class="form-check-label" for="invalidCheck2">
Agree to terms and conditions
</label>
</div>
</div>
<button class="btn btn-primary" type="submit">Submit form</button>
</form>
Lehlakore la seva
Re kgothaletša go diriša netefatšo ya lehlakore la moreki, eupša ge go ka direga gore o nyaka netefatšo ya lehlakore la seva, o ka bontšha mafelo a foromo ao a sa šomego le ao a šomago ka .is-invalid
le .is-valid
. Hlokomela gore .invalid-feedback
gape e thekgwa ka diklase tše.
Bakeng sa mafelo ao a sa šomego, netefatša gore molaetša wa ditshwaotshwao/phošo wo o sa šomego o amana le tšhemo ya foromo ya maleba ka go šomiša aria-describedby
. Sebopego se se dumelela go šupša go feta e tee id
, ge go ka direga gore tšhemo e šetše e šupa sengwalwa sa tlaleletšo sa foromo.
<form>
<div class="form-row">
<div class="col-md-6 mb-3">
<label for="validationServer01">First name</label>
<input type="text" class="form-control is-valid" id="validationServer01" value="Mark" required>
<div class="valid-feedback">
Looks good!
</div>
</div>
<div class="col-md-6 mb-3">
<label for="validationServer02">Last name</label>
<input type="text" class="form-control is-valid" id="validationServer02" value="Otto" required>
<div class="valid-feedback">
Looks good!
</div>
</div>
</div>
<div class="form-row">
<div class="col-md-6 mb-3">
<label for="validationServer03">City</label>
<input type="text" class="form-control is-invalid" id="validationServer03" aria-describedby="validationServer03Feedback" required>
<div id="validationServer03Feedback" class="invalid-feedback">
Please provide a valid city.
</div>
</div>
<div class="col-md-3 mb-3">
<label for="validationServer04">State</label>
<select class="custom-select is-invalid" id="validationServer04" aria-describedby="validationServer04Feedback" required>
<option selected disabled value="">Choose...</option>
<option>...</option>
</select>
<div id="validationServer04Feedback" class="invalid-feedback">
Please select a valid state.
</div>
</div>
<div class="col-md-3 mb-3">
<label for="validationServer05">Zip</label>
<input type="text" class="form-control is-invalid" id="validationServer05" aria-describedby="validationServer05Feedback" required>
<div id="validationServer05Feedback" class="invalid-feedback">
Please provide a valid zip.
</div>
</div>
</div>
<div class="form-group">
<div class="form-check">
<input class="form-check-input is-invalid" type="checkbox" value="" id="invalidCheck3" aria-describedby="invalidCheck3Feedback" required>
<label class="form-check-label" for="invalidCheck3">
Agree to terms and conditions
</label>
<div id="invalidCheck3Feedback" class="invalid-feedback">
You must agree before submitting.
</div>
</div>
</div>
<button class="btn btn-primary" type="submit">Submit form</button>
</form>
Dielemente tše di thekgwago
Mekgwa ya netefatšo e a hwetšagala bakeng sa ditaolo tša foromo le dikarolo tše di latelago:
<input>
s le<textarea>
s ka.form-control
<select>
s ka.form-control
goba.custom-select
.form-check
s.custom-checkbox
s le.custom-radio
s.custom-file
<form class="was-validated">
<div class="mb-3">
<label for="validationTextarea">Textarea</label>
<textarea class="form-control is-invalid" id="validationTextarea" placeholder="Required example textarea" required></textarea>
<div class="invalid-feedback">
Please enter a message in the textarea.
</div>
</div>
<div class="custom-control custom-checkbox mb-3">
<input type="checkbox" class="custom-control-input" id="customControlValidation1" required>
<label class="custom-control-label" for="customControlValidation1">Check this custom checkbox</label>
<div class="invalid-feedback">Example invalid feedback text</div>
</div>
<div class="custom-control custom-radio">
<input type="radio" class="custom-control-input" id="customControlValidation2" name="radio-stacked" required>
<label class="custom-control-label" for="customControlValidation2">Toggle this custom radio</label>
</div>
<div class="custom-control custom-radio mb-3">
<input type="radio" class="custom-control-input" id="customControlValidation3" name="radio-stacked" required>
<label class="custom-control-label" for="customControlValidation3">Or toggle this other custom radio</label>
<div class="invalid-feedback">More example invalid feedback text</div>
</div>
<div class="mb-3">
<select class="custom-select" required>
<option value="">Choose...</option>
<option value="1">One</option>
<option value="2">Two</option>
<option value="3">Three</option>
</select>
<div class="invalid-feedback">Example invalid custom select feedback</div>
</div>
<div class="custom-file mb-3">
<input type="file" class="custom-file-input" id="validatedCustomFile" required>
<label class="custom-file-label" for="validatedCustomFile">Choose file...</label>
<div class="invalid-feedback">Example invalid custom file feedback</div>
</div>
<div class="mb-3">
<div class="input-group is-invalid">
<div class="input-group-prepend">
<span class="input-group-text" id="validatedInputGroupPrepend">@</span>
</div>
<input type="text" class="form-control is-invalid" aria-describedby="validatedInputGroupPrepend" required>
</div>
<div class="invalid-feedback">
Example invalid input group feedback
</div>
</div>
<div class="mb-3">
<div class="input-group is-invalid">
<div class="input-group-prepend">
<label class="input-group-text" for="validatedInputGroupSelect">Options</label>
</div>
<select class="custom-select" id="validatedInputGroupSelect" required>
<option value="">Choose...</option>
<option value="1">One</option>
<option value="2">Two</option>
<option value="3">Three</option>
</select>
</div>
<div class="invalid-feedback">
Example invalid input group feedback
</div>
</div>
<div class="input-group is-invalid">
<div class="custom-file">
<input type="file" class="custom-file-input" id="validatedInputGroupCustomFile" required>
<label class="custom-file-label" for="validatedInputGroupCustomFile">Choose file...</label>
</div>
<div class="input-group-append">
<button class="btn btn-outline-secondary" type="button">Button</button>
</div>
</div>
<div class="invalid-feedback">
Example invalid input group feedback
</div>
</form>
Dikeletšo tša didirišwa
Ge e le gore peakanyo ya gago ya foromo e e dumelela, o ka fapantšha .{valid|invalid}-feedback
diklase ka .{valid|invalid}-tooltip
diklase go bontšha ditshwaotshwao tša netefatšo ka go keletšo ya sedirišwa ya setaele. Kgonthišetša gore o na le motswadi yo a nago le position: relative
godimo ga yona bakeng sa go beakanya keletšo ya didirišwa. Mohlaleng wo o lego ka mo tlase, diklase tša rena tša dikholomo di šetše di na le se, eupša porojeke ya gago e ka nyaka peakanyo ye nngwe.
<form class="needs-validation" novalidate>
<div class="form-row">
<div class="col-md-6 mb-3">
<label for="validationTooltip01">First name</label>
<input type="text" class="form-control" id="validationTooltip01" value="Mark" required>
<div class="valid-tooltip">
Looks good!
</div>
</div>
<div class="col-md-6 mb-3">
<label for="validationTooltip02">Last name</label>
<input type="text" class="form-control" id="validationTooltip02" value="Otto" required>
<div class="valid-tooltip">
Looks good!
</div>
</div>
</div>
<div class="form-row">
<div class="col-md-6 mb-3">
<label for="validationTooltip03">City</label>
<input type="text" class="form-control" id="validationTooltip03" required>
<div class="invalid-tooltip">
Please provide a valid city.
</div>
</div>
<div class="col-md-3 mb-3">
<label for="validationTooltip04">State</label>
<select class="custom-select" id="validationTooltip04" required>
<option selected disabled value="">Choose...</option>
<option>...</option>
</select>
<div class="invalid-tooltip">
Please select a valid state.
</div>
</div>
<div class="col-md-3 mb-3">
<label for="validationTooltip05">Zip</label>
<input type="text" class="form-control" id="validationTooltip05" required>
<div class="invalid-tooltip">
Please provide a valid zip.
</div>
</div>
</div>
<button class="btn btn-primary" type="submit">Submit form</button>
</form>
Go dira gore e be ya gago
E re netefatso ka customized ka Sass le ' $form-validation-states
mapa. E hwetšwa ka faeleng ya rena _variables.scss
, mmapa wo wa Sass o looped godimo go tšweletša maemo a go se fetoge valid
/ invalid
a netefatšo. Go akaretšwa mmapa wo o tsentšwego ka gare ga sehlaga bakeng sa go tlwaetša mmala le leswao la mmušo o mongwe le o mongwe. Le ge go se na dinaga tše dingwe tšeo di thekgwago ke diphensele, bao ba dirišago mekgwa ya tlwaelo ba ka oketša gabonolo ditshwaotshwao tša foromo tše di raraganego kudu.
Hle ela hloko gore ga re kgothaletše go tlwaetša dikelo tše ntle le go fetoša gape form-validation-state
mixin.
// Sass map from `_variables.scss`
// Override this and recompile your Sass to generate different states
$form-validation-states: map-merge(
(
"valid": (
"color": $form-feedback-valid-color,
"icon": $form-feedback-icon-valid
),
"invalid": (
"color": $form-feedback-invalid-color,
"icon": $form-feedback-icon-invalid
)
),
$form-validation-states
);
// Loop from `_forms.scss`
// Any modifications to the above Sass map will be reflected in your compiled
// CSS via this loop.
@each $state, $data in $form-validation-states {
@include form-validation-state($state, map-get($data, color), map-get($data, icon));
}
Netefatšo ya sehlopha sa tsenyo
Go lemoga gore ke dielemente dife tšeo di nyakago dikhutlo tše di kgokologilego ka gare ga sehlopha sa tsenyo ka netefatšo, sehlopha sa tsenyo se nyaka sehlopha sa tlaleletšo .has-validation
.
<div class="input-group has-validation">
<div class="input-group-prepend">
<span class="input-group-text">@</span>
</div>
<input type="text" class="form-control" required>
<div class="invalid-feedback">
Please choose a username.
</div>
</div>
Diforomo tša tlwaelo
Bakeng sa go tlwaetša le go feta le go se fetoge ga sephephediši sa sefapano, diriša dielemente tša rena tša foromo ya tlwaelo ka botlalo go tšea legato la dilo tša go se fetoge tša sephephediši. Di agilwe godimo ga go swaya ga semantiki le mo go fihlelelwago, ka fao ke diphetogo tše di tiilego tša taolo efe goba efe ya foromo ya go se fetoge.
Mapokisi a go hlahloba le diradio
Lepokisi le lengwe le le lengwe la go hlahloba le radio <input>
le go <label>
kopanya di phuthetšwe ka go a <div>
go hlama taolo ya rena ya tlwaelo. Ka sebopego, ye ke mokgwa o swanago le wa rena wa go se fetoge .form-check
.
Re diriša mokgethi wa bana babo rena ( ~
) bakeng sa <input>
dilete tša rena ka moka—go swana le :checked
—go setaele gabotse sešupo sa rena sa foromo ya tlwaelo. Ge re kopantšwe le .custom-control-label
sehlopha, re ka boela ra setaele sa sengwalwa sa selo se sengwe le se sengwe go ya ka seemo sa <input>
's.
Re uta default <input>
ka opacity
le go šomiša .custom-control-label
go aga sešupo se sefsa sa foromo ya tlwaelo lefelong la sona ka ::before
le ::after
. Ka bomadimabe re ka se kgone go aga ya tlwaelo go tšwa go feela ka <input>
gobane CSS's content
ga e šome go elemente yeo.
Ka e re hlahlojoa, re sebelisa base64 embedded SVG diaekhone ho tloha Open Iconic . Se se re fa taolo ye kaone ya go dira setaele le go beakanya go ralala le diphensele le didirišwa.
Mapokisi a go hlahloba
<div class="custom-control custom-checkbox">
<input type="checkbox" class="custom-control-input" id="customCheck1">
<label class="custom-control-label" for="customCheck1">Check this custom checkbox</label>
</div>
Mapokisi a go hlahloba a tlwaelo a ka šomiša gape :indeterminate
sehlopha sa maaka ge se beakantšwe ka seatla ka JavaScript (ga go na seka sa HTML seo se lego gona sa go se laetša).
Ge e ba o diriša jQuery, selo se sengwe sa go swana le se se swanetše go lekana:
$('.your-checkbox').prop('indeterminate', true)
Diradio
<div class="custom-control custom-radio">
<input type="radio" id="customRadio1" name="customRadio" class="custom-control-input">
<label class="custom-control-label" for="customRadio1">Toggle this custom radio</label>
</div>
<div class="custom-control custom-radio">
<input type="radio" id="customRadio2" name="customRadio" class="custom-control-input">
<label class="custom-control-label" for="customRadio2">Or toggle this other custom radio</label>
</div>
Ka gare ga mothaladi
<div class="custom-control custom-radio custom-control-inline">
<input type="radio" id="customRadioInline1" name="customRadioInline" class="custom-control-input">
<label class="custom-control-label" for="customRadioInline1">Toggle this custom radio</label>
</div>
<div class="custom-control custom-radio custom-control-inline">
<input type="radio" id="customRadioInline2" name="customRadioInline" class="custom-control-input">
<label class="custom-control-label" for="customRadioInline2">Or toggle this other custom radio</label>
</div>
Šitišitšwe
Mapokisi a go hlahloba a tlwaelo le diradio le tšona di ka šitišwa. Oketša disabled
seka sa boolean go <input>
le sešupo sa tlwaelo le tlhalošo ya leina di tla bewa setaele ka go iketla.
<div class="custom-control custom-checkbox">
<input type="checkbox" class="custom-control-input" id="customCheckDisabled1" disabled>
<label class="custom-control-label" for="customCheckDisabled1">Check this custom checkbox</label>
</div>
<div class="custom-control custom-radio">
<input type="radio" name="radioDisabled" id="customRadioDisabled2" class="custom-control-input" disabled>
<label class="custom-control-label" for="customRadioDisabled2">Toggle this custom radio</label>
</div>
Di-switjha
Switšhi e na le go swaya ga lepokisi la go hlahloba la tlwaelo eupša e šomiša .custom-switch
sehlopha go tšweletša switšhi ya go fetoša. Switjha hape tšehetsa disabled
tšobotsi.
<div class="custom-control custom-switch">
<input type="checkbox" class="custom-control-input" id="customSwitch1">
<label class="custom-control-label" for="customSwitch1">Toggle this switch element</label>
</div>
<div class="custom-control custom-switch">
<input type="checkbox" class="custom-control-input" disabled id="customSwitch2">
<label class="custom-control-label" for="customSwitch2">Disabled switch element</label>
</div>
Kgetha menu ya
Dimenu tša tlwaelo <select>
di nyaka fela sehlopha sa tlwaelo, .custom-select
go hlohleletša mekgwa ya tlwaelo. Mekgwa ya tlwaelo e lekanyeditšwe go <select>
ponagalo ya mathomo ya 's gomme e ka se fetoše <option>
s ka lebaka la mellwane ya sephephediši.
<select class="custom-select">
<option selected>Open this select menu</option>
<option value="1">One</option>
<option value="2">Two</option>
<option value="3">Three</option>
</select>
O ka kgetha gape go tšwa go dikgetho tša tlwaelo tše nnyane le tše kgolo go swana le ditseno tša rena tša sengwalwa tša bogolo bjo bo swanago.
<select class="custom-select custom-select-lg mb-3">
<option selected>Open this select menu</option>
<option value="1">One</option>
<option value="2">Two</option>
<option value="3">Three</option>
</select>
<select class="custom-select custom-select-sm">
<option selected>Open this select menu</option>
<option value="1">One</option>
<option value="2">Two</option>
<option value="3">Three</option>
</select>
Sebopego multiple
se a thekgwa gape:
<select class="custom-select" multiple>
<option selected>Open this select menu</option>
<option value="1">One</option>
<option value="2">Two</option>
<option value="3">Three</option>
</select>
Bjalo ka ge go le bjalo ka size
seka:
<select class="custom-select" size="3">
<option selected>Open this select menu</option>
<option value="1">One</option>
<option value="2">Two</option>
<option value="3">Three</option>
</select>
Mehutahuta
Hlama <input type="range">
ditaolo tša tlwaelo ka .custom-range
. Pina (morago) le monwana o mogolo (boleng) ka bobedi di rulagantšwe go tšwelela go swana go ralala le diphensele. Bjalo ka ge e le feela IE le Firefox tšeo di thekgago go “tlatša” pina ya tšona go tšwa ka go le letshadi goba ka go le letona la monwana o mogolo e le mokgwa wa go bontšha tšwelopele ka pono, ga bjale ga re e thekge.
<label for="customRange1">Example range</label>
<input type="range" class="custom-range" id="customRange1">
Range inputs na le boleng implicit bakeng sa min
le max
— 0
le 100
, ka ho latellana. O ka laetša dikelo tše mpsha tša bao ba šomišago dika tša min
le max
.
<label for="customRange2">Example range</label>
<input type="range" class="custom-range" min="0" max="5" id="customRange2">
Ka default, fapaneng inputs “snap” ho boleng palo e feletseng. Go fetola se, o ka laeta step
boleng. Mohlaleng wo o lego ka mo tlase, re oketša palo ya megato gabedi ka go diriša step="0.5"
.
<label for="customRange3">Example range</label>
<input type="range" class="custom-range" min="0" max="5" step="0.5" id="customRange3">
Sephephediši sa faele
Tsenyo ya faele ke yeo e nago le gnarly kudu ya sehlopha gomme e nyaka JavaScript ya tlaleletšo ge o rata go di kgokaganya ka Kgetha faele ye e šomago... le sengwalwa sa leina la faele seo se kgethilwego.
<div class="custom-file">
<input type="file" class="custom-file-input" id="customFile">
<label class="custom-file-label" for="customFile">Choose file</label>
</div>
Re uta faele ya go se fetoge <input>
ka opacity
gomme go e na le moo re setaele <label>
. Konopo e tšweletšwa le go bewa ka ::after
. Labofelo, re tsebagatša a width
le height
godimo ga <input>
bakeng sa sekgoba se se swanetšego bakeng sa dikagare tše di dikologilego.
Go fetolela goba go tlwaetša dithapo ka SCSS
Sehlopha sa :lang()
maaka se šomišwa go dumelela go fetolelwa ga sengwalwa sa “Browse” go malemeng a mangwe. Tloša goba o oketše dikeno go $custom-file-text
phetogo ya Sass ka leswao la polelo la maleba le dithapo tša selegae. Dithapo tša Seisemane di ka rulaganywa ka tsela e swanago. Ka mohlala, mo ke kamoo motho a ka oketšago phetolelo ya Sepaniši (khoutu ya polelo ya Sepaniši ke es
):
$custom-file-text: (
en: "Browse",
es: "Elegir"
);
Mona ke lang(es)
ka tiro ka tsenyo ya faele ya tlwaelo bakeng sa phetolelo ya Sepanishe:
<div class="custom-file">
<input type="file" class="custom-file-input" id="customFileLang" lang="es">
<label class="custom-file-label" for="customFileLang">Seleccionar Archivo</label>
</div>
O tla swanelwa ke go beakanya polelo ya tokumente ya gago (goba sehlare sa ka fasana sa yona) ka nepagalo gore sengwalwa se se nepagetšego se bontšhwe. Se se ka dirwa ka go šomiša seka lang
godimo ga <html>
elemente goba Content-Language
hlogo ya HTTP , gare ga mekgwa ye mengwe.
Go fetolela goba go tlwaetša dithapo ka HTML
Bootstrap e fana gape ka tsela ya go fetolela sengwalwa sa “Browse” ka HTML ka data-browse
seka seo se ka okeletšwago go leina la go tsenya la tlwaelo (mohlala ka Sedache):
<div class="custom-file">
<input type="file" class="custom-file-input" id="customFileLangHTML">
<label class="custom-file-label" for="customFileLangHTML" data-browse="Bestand kiezen">Voeg je document toe</label>
</div>