Fieldsets Using Bootstrap Grids - html

I have the following markup using bootstrap grids:
<form id="store-form" class="user-form">
<div class="row">
<div class="col-sm-6">
<fieldset id="store-form-store-fields">
<label>Store Nickname</label>
<input id="store-nickname-field" type="text" name="nickname" required class="form-control">
</fieldset>
</div>
<fieldset id="store-form-location-fields">
<div class="col-sm-6">
<label>Store Address</label>
<input id="store-street-field" type="text" name="street" required class="form-control">
</div>
<div class="col-sm-6">
<label>City</label>
<input id="store-city-field" type="text" name="city" required class="form-control">
</div>
<div class="col-sm-3">
<label>State</label>
<select id="store-state-field" name="state_id" required class="form-control">
<option>- Select a State -</option>
<option value="MA">Massachusetts</option>
<option value="CA">California</option>
</select>
</div>
<div class="col-sm-3">
<label>Zip Code</label>
<input id="store-zipcode-field" type="text" name="zipcode" required class="form-control">
</div>
</fieldset>
</div>
<div class="submit-wrapper">
<button id="store-form-submit" type="submit" class="btn btn-primary submit-button">Save</button>
</div>
</form>
As you can see, I'm trying to use fieldsets to group the fields into two groups. I need to do this so that I can create Backbone.js view for each group of fields separately. Obviously this breaks the grid, since I have an immediate child of .row that isn't a column div.
Is there any way at all to make fieldsets work with a form that is layed out using Bootstrap grids?
Edit for clarification: My goal is for the layout to behave the same as if the fieldsets were removed from the example.

What about wrapping the second <fieldset> in a div.col-md-6 and putting all the contents of the second <fieldset> in div.row? That way you are not skipping the css column definition. Let me know if that helps.
UPDATE:
I modified the code to use responsive resets and col-md-pull/col-sm-pull. Seems to remain responsive. This may be closest solution possible as you would not be able to properly close the col definition <div> within that fieldset to get proper clearing.
http://jsfiddle.net/s9baun7c/4/
<form id="store-form" class="user-form">
<div class="row">
<div class="col-sm-6">
<fieldset id="store-form-store-fields">
<label>Store Nickname</label>
<input id="store-nickname-field" type="text" name="nickname" required class="form-control" />
</fieldset>
</div>
<fieldset id="store-form-location-fields">
<div class="col-sm-12">
<label>Store Address</label>
<input id="store-street-field" type="text" name="street" required class="form-control" />
</div>
<div class="clearfix visible-md-block"></div>
<div class="clearfix visible-sm-block"></div>
<div class="row">
<div class="col-md-12">
<div class="col-sm-12 col-sm-pull-12 col-sm-pull-12">
<label>City</label>
<input id="store-city-field" type="text" name="city" required class="form-control" />
</div>
<div class="clearfix visible-md-block"></div>
<div class="clearfix visible-sm-block"></div>
<div class="col-sm-6 col-sm-pull-12 col-sm-pull-12">
<label>State</label>
<select id="store-state-field" name="state_id" required class="form-control">
<option>- Select a State -</option>
<option value="MA">Massachusetts</option>
<option value="CA">California</option>
</select>
</div>
<div class="col-sm-6 col-sm-pull-12 col-sm-pull-12">
<label>Zip Code</label>
<input id="store-zipcode-field" type="text" name="zipcode" required class="form-control" />
</div>
</div>
</div>
</fieldset>
</div>
<br>
<div class="submit-wrapper">
<button id="store-form-submit" type="submit" class="btn btn-primary submit-button">Save</button>
</div>
</form>

Related

issue with forms in bootstrap and html

I have a bit of a problem and i need some help. I am learning new things and trying to get some skills with the time spend on learning.
I want to make this picture and forms look the same as the picture. I am posting my code
enter image description here
index.html
<div class="jumbotron">
<div class="row">
<div class="col-md-6 col-sm-6">
<img class="img-responsive" src="img/lqvopodravnenasnimka.jpg" alt="smiley face">
</div> <!--col-md-5-->
<div class="col-md-6 col-sm-6">
<h3>Send Request</h3>
<p id="mainparagraph">Заповядайте в нашия нов хотел Grand Hotel Gergana. Ние Ви предлагаме отлични условия, където можете да прекарате своите ценни свободни дни.</p>
<form name="myForm" action="#" onsubmit="return validateForm()" method="post">
<div class="row">
<div class="col-md-6">
<div class="form-group form-group-sm" style="margin-top:20px;">
<label for="firstname" class="control-label">Name</label> <!--name-->
<br>
<input type="text" class="form-control" id="firstname" style="width:100%;" name="fname">
</div><!-- form-group-->
</div><!--col-md-5-->
<div class="col-md-6">
<div class="form-group form-group-sm" style="margin-top:20px;">
<label for="surname" class="control-label">Surname</label> <!--surname -->
<br>
<input type="text" class="form-control" id="surname" style="width:100%;" name="sname">
</div><!-- form-group-->
</div><!--col-md-5-->
</div><!--row-->
<div class="row">
<div class="col-md-12">
<div class="form-group form-group-sm" style="margin-top:20px;">
<label for="email" class="control-label">Email</label>
<br>
<input type="text" class="form-control" id="email" style="width:100%;" name="mail">
</div>
</div>
</div><!--row-->
<div class="row">
<div class="col-sm-12">
<div class="form-group form-group-sm" style="margin-top:20px;">
<label for="phone" class="control-label">Mobile phone</label>
<!--<span class="glyphicon glyphicon-arrow-right"><p style="color:gray; font-style:italic; font-size:0.7em;">Sample: +352XXXXXXXXX</p> -->
<br>
<input type="phone" class="form-control" id="phone" style="width:100%;" name="mphone">
</div>
</div>
</div><!--row-->
<div class="row">
<div class="col-md-6">
<div class="form-group form-group-sm" style="margin-top:20px;">
<label for="date" class="control-label">Date of birth</label>
<br>
<input type="number" class="form-control" id="number" Placeholder="DD" style="width:55px;" name="day">
<input type="number" class="form-control" id="number" Placeholder="MM" style="width:55px;" name="month">
<input type="number" class="form-control" id="number" Placeholder="YYYY" style="width:90px;" name="year">
</div>
</div><!--col-md-6-->
<div class="col-md-6">
<div class="form-group form-group-sm" >
<label for="text" class="control-label" style="margin-top:20px;">Nationality</label>
<br>
<select class="options" name="cars" style="width:100%;">
<option value="България">България</option>
<option value="Румъния">Румъния</option>
<option value="Гърция">Гърция</option>
<option value="Сърбия">Сърбия</option>
</select>
</div><!--form-group-->
</div>
<div class="col-md-12">
<input type="submit" value="SAMPLE BUTTON">
</div>
</div><!--row-->
</form>
</div><!--col-md-7-->
Its quite a simple fix. You were really close! Firstly with Bootstrap you need to have a container, so that's a class that would be on your main div that holds everything so for this instance it would be your jumbotron div.
<div class="jumbotron container">
This will format 90% of what you are trying to achieve into a neat box where all the cols work in harmony with each other.
As for the input boxes, I see you were having difficulty with your date inputs. This too is an easy fix. Simply add the following code to your css:
#number {
float: left;
}
This will push them close together as seen in your picture.
Working example here - https://codepen.io/anon/pen/MoqRMK
I am sure you are experienced enough to make any other required changes.

Twitter Bootstrap 3 Checkbox Won't Align with rest of Form

I'm having some trouble with a Twitter Bootstrap form alignment. I have a checkbox that causes the below div's to incorrectly line up with the grid because it's height is only 70px tall when the div next to it is 74px. I could add the CSS to force it to the pixel height needed (see id "test") but I don't want this stay a fixed height when content responds for smaller screens. What would be the best way to fix this?
<div class="container-fluid appointment">
<div class="container">
<div class="row">
<h2 class="text-center">Appointment Request</h2>
<form>
<div class="col-sm-4">
<div class="form-group">
<label for="">Phone Number:</label>
<input type="tel" class="form-control" id="phone">
</div>
</div>
<div class="col-sm-8">
<div class="form-group">
<label for="email">Email Address:</label>
<input type="email" class="form-control" id="email">
</div>
</div>
<div class="col-sm-7">
<div class="form-group">
<label for="petname">Pet's Name:</label>
<input type="text" class="form-control" id="petname">
</div>
</div>
<div class="col-sm-5" id="test">
<div class="form-group">
<label>Is your pet neutered or spayed?</label>
<div class="checkbox">
<label for="neutered"><input type="checkbox" id="neutspay">Neutered/Spayed</label>
</div>
</div>
</div>
<div class="col-sm-4">
<div class="form-group">
<label for="pettype">Pet Type:</label>
<select class="form-control" id="pettype">
<option>Select Pet Type...</option>
</select>
</div>
</div>
<div class="col-sm-4">
<div class="form-group">
<label for="breed">Breed Type:</label>
<select class="form-control" id="breed">
<option>Select Breed...</option>
</select>
</div>
</div>
<div class="col-sm-2">
<div class="form-group">
<label for="age">Pet Age:</label>
<select class="form-control" id="age">
<option>Select Pet Age...</option>
<option value="less than 1">Less than 1 year</option>
<option value="1">1 Year</option>
</select>
</div>
</div>
<div class="col-sm-12 text-center">
<div class="form-group">
<button type="submit" class="btn btn-lg">Send Appointment</button>
</div>
</div>
</form>
</div>
</div>
</div>
just add a class "clearfix" for the div containing the checkbox as
<div class="col-sm-5" id="test">
<div class="form-group clearfix">
<label>Is your pet neutered or spayed?</label>
<div class="checkbox">
<label for="neutered"><input type="checkbox" id="neutspay">Neutered/Spayed</label>
</div>
</div>
</div>

Extend datepicker to start with dropdown using bootstrap

I have a requirement to display Datepicker with Dropdown as a single control, I have tried many samples available on the internet but they do not work for me.
My base code is given below with style in which I have to merge them.
<fieldset>
<div class="form-group">
<label class="col-sm-2 control-label">Date</label>
<div class="col-sm-4">
<select name="Year" class="form-control" ng-model="Year" required>
<option>2016</option>
<option>2015</option>
<option>2014</option>
</select>
<div ng-messages="form.formValidate.select.$error" ng-if="form.formValidate.$submitted" class="text-danger"><span ng-message="required">This field is required</span></div>
<div class="ui-datepicker shadow-clear">
<p class="input-group">
<input type="text" name="date" required="" class="form-control" />
<span class="input-group-btn">
<button type="button" class="btn btn-default"><em class="ion-calendar"></em></button>
</span>
</p>
<div ng-messages="form.formValidate.date.$error" ng-if="form.formValidate.$submitted" class="text-danger"><span ng-message="required">This field is required</span></div>
</div>
</div>
</div>
</fieldset>
Any kind of help would be appreciated.
Thanks in advance!
Edit
Opps! I missed mentioning that both controls should be side by side as displayed in below image.
Edit2
http://www.bootply.com/Tftcr9VVrH
I wrapped the elements in a div with class="form-inline" and put each group of elements into a div with class="form-group". I forked your bootply here
<fieldset>
<div class="form-inline">
<div class="form-group">
<label for="Year">Date</label>
<select name="Year" class="form-control" required="" ng-model="Year">
<option>2016</option>
<option>2015</option>
<option>2014</option>
</select>
<div class="text-danger" ng-if="form.formValidate.$submitted" ng-messages="form.formValidate.select.$error"><span ng-message="required">This field is required</span></div>
</div>
<div class="form-group">
<div class="ui-datepicker shadow-clear">
<div class="input-group">
<input name="date" class="form-control" required="" type="text">
<span class="input-group-btn">
<button class="btn btn-default" type="button"><em class="glyphicon glyphicon-calendar"></em></button>
</span>
</div>
<div class="text-danger" ng-if="form.formValidate.$submitted" ng-messages="form.formValidate.date.$error"><span ng-message="required">This field is required</span></div>
</div>
</div>

Bootstrap: col-sm-6 expands above other columns on xs screen size

I'm experiencing an odd behaviour in Bootstrap where a col-sm-6 is expanding on top of the sibling column above it, which renders the sibling column unclickable.
Please see source code and live demo here: Codepen
Resize the output window to xs size (below 768px) to experience the issue).
The checkbox for 'As above' is unclickable because the phyiscal address 'Address line 1' is expanding above it, creating a sort of barrier.
The issue can be solved by adding 'col-xs-12' in addition to the 'col-sm-6', but Bootstrap should figure this one out by itself without this (as it normally does). Any ideas what is causing this?
EDIT:
One could argue that I should put all my fields in different rows, but for various reasons I'd like to keep everything within one row and let Bootstrap figure out the flow of the items, which normally works fine.
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css" rel="stylesheet"/>
<div class="container">
<div class="row">
<div class="col-xs-12">
<h3>Postal address</h3>
</div>
<div class="col-sm-6">
<div class="form-group">
<label for="inputPostalAddressLine1">Address line 1*</label>
<input type="text" class="form-control" id="inputPostalAddressLine1" required="" data-parsley-required-message="Please enter your postal address.">
</div>
</div>
<div class="col-sm-6">
<div class="form-group">
<label for="inputPostalAddressLine2">Address line 2</label>
<input type="text" class="form-control" id="inputPostalAddressLine2">
</div>
</div>
<div class="clearfix hidden-xs"></div>
<div class="col-sm-6">
<div class="form-group">
<label for="inputPostalState">State*</label>
<select class="form-control" id="inputPostalState" required="" data-parsley-required-message="Please select the state from the dropdown.">
<option value="">Please Select</option>
<option value="nsw">NSW</option>
<option value="nt">NT</option>
<option value="qld">QLD</option>
<option value="sa">SA</option>
<option value="tas">TAS</option>
<option value="vic">VIC</option>
<option value="wa">WA</option>
</select>
</div>
</div>
<div class="col-sm-6">
<div class="form-group">
<label for="inputPostalPostcode">Postcode*</label>
<input type="text" class="form-control" id="inputPostalPostcode" required="" data-parsley-error-message="Please enter a valid postcode." data-parsley-length="[4, 4]" data-parsley-type="digits">
</div>
</div>
<div class="clearfix hidden-xs"></div>
<div class="col-sm-6">
<div class="form-group">
<label for="inputPostalSuburb">Suburb*</label>
<input type="text" class="form-control" id="inputPostalSuburb" required="" data-parsley-required-message="Please enter your suburb.">
</div>
</div>
<div class="col-xs-12">
<h3>Physical address</h3>
</div>
<div class="col-xs-12">
<div class="form-group">
<div class="checkbox checkbox-default">
<label>
<input type="checkbox" value="" id="use-postal-address" data-parsley-multiple="use-postal-address">
<span class="icon"></span>
<span class="text">As above (use postal address)</span>
</label>
</div>
</div>
</div>
<div class="col-sm-6 ">
<div class="form-group">
<label for="inputPhysicalAddressLine1">Address line 1*</label>
<input type="text" class="form-control" id="inputPhysicalAddressLine1" required="" data-parsley-required-message="Please enter your physical address.">
</div>
</div>
<div class="col-sm-6">
<div class="form-group">
<label for="inputPhysicalAddressLine2">Address line 2</label>
<input type="text" class="form-control" id="inputPhysicalAddressLine2">
</div>
</div>
<div class="clearfix hidden-xs"></div>
<div class="col-sm-6">
<div class="form-group">
<label for="inputPhysicalState">State*</label>
<input type="text" class="form-control" id="inputPhysicalState" value="NSW" disabled="disabled">
</div>
</div>
<div class="col-sm-6">
<div class="form-group">
<label for="inputPhysicalPostcode">Postcode*</label>
<input type="text" class="form-control" id="inputPhysicalPostcode" required="" data-parsley-error-message="Please enter a valid postcode." data-parsley-length="[4, 4]" data-parsley-type="digits">
</div>
</div>
<div class="clearfix hidden-xs"></div>
<div class="col-sm-6">
<div class="form-group">
<label for="inputPhysicalSuburb">Suburb*</label>
<input type="text" class="form-control" id="inputPhysicalSuburb" required="" data-parsley-required-message="Please enter your suburb.">
</div>
</div>
</div>
</div>
I think you're not clearing your floats properly across media queries.
Add .col-sm-6{overflow:hidden} to see if it solves it, then try to clear your floats whenever possible.
Also, read up on this, it might be helpful

Make Bootstrap form inline and better layed out

I am quite new to bootstrap, I have build the following form, but I want to know if someone can please assist me and help me make this form more inline as I think from a layout perspective there is a better way out there, but I really do not know how to achieve it, I will appreciate all the help.
Essentially help me make my form more aesthetically pleasing.
HTML:
<!-- Form Name -->
<legend>Order Form</legend>
<form class="form-horizontal form-shadow">
<fieldset>
<!-- Text input-->
<div class="form-group">
<label class="col-md-4 control-label" for="email">E-mail</label>
<div class="col-md-4">
<input id="email" name="email" type="text" placeholder="Enter E-mail" class="form-control input-md" required="">
</div>
</div>
<!-- Select Basic -->
<div class="form-group">
<label class="col-md-4 control-label" for="tile">Select Title</label>
<div class="col-md-4">
<select id="tile" name="tile" class="form-control">
<option value="Miss">Miss</option>
<option value="Mr">Mr</option>
<option value="Mrs">Mrs</option>
<option value="Ms">Ms</option>
<option value="Dr">Dr</option>
<option value="Rev">Rev</option>
<option value="Other">Other</option>
</select>
</div>
</div>
<!-- Text input-->
<div class="form-group">
<label class="col-md-4 control-label" for="name">Name</label>
<div class="col-md-4">
<input id="name" name="name" type="text" placeholder="Enter Name" class="form-control input-md" required="">
</div>
</div>
<!-- Text input-->
<div class="form-group">
<label class="col-md-4 control-label" for="surname">Surname</label>
<div class="col-md-4">
<input id="surname" name="surname" type="text" placeholder="Enter Surname" class="form-control input-md" required="">
</div>
</div>
<!-- Textarea -->
<div class="form-group">
<label class="col-md-4 control-label" for="address">Address</label>
<div class="col-md-4">
<textarea class="form-control" id="address" name="address" placeholder="Enter Address"></textarea>
</div>
</div>
<!-- Prepended text-->
<div class="form-group">
<label class="col-md-4 control-label" for="cell"></label>
<div class="col-md-4">
<div class="input-group">
<span class="input-group-addon">Cell</span>
<input id="cell" name="cell" class="form-control" placeholder="Enter Cellphone" type="text" required="">
</div>
</div>
</div>
<!-- Prepended text-->
<div class="form-group">
<label class="col-md-4 control-label" for="fax"></label>
<div class="col-md-4">
<div class="input-group">
<span class="input-group-addon">Fax</span>
<input id="fax" name="fax" class="form-control" placeholder="Enter Fax" type="text" required="">
</div>
</div>
</div>
This is what it looks like right now:
This is the effect that I would like:
sourround the form with
for the inputs i think you could use the col-md-6 or 8
also, you can apply multiple col types
for the radio options try something like this
<div class="radio">
<label>
<input type="radio" name="optionsRadios" id="optionsRadios1" value="option1" checked>
Option one is this and that—be sure to include why it's great
</label>
</div>.
and always, if you don't like the background color, you could change it in your own CSS file, you even could use the same class for bootstrap and your css (bootstrap is just that, a css)
also, the classes PULL-RIGHT and PULL-LEFT can help you
hope this can help you!