I cannot get this icon to sit inside the field, I can only get it either above or below:
<div class="form-group">
<label for="inputFirstName">First Name</label>
<div class="input-group">
<div class="input-group addon">
<i class="fa fa-user">
</i>
<input type="text" class="form-control" id="inputFirstName">
</div>
</div>
</div>
.form-group i{
color: #ccc;
float: right;
margin-right: 6px;
position: relative;
z-index: 2;
}
I have tried reading nearly every post on here but I am getting quite frustrated.
I think what you were looking for was the class "input-group-prepend" This is from v 4.0.0 I don't know how it was done in previous versions. I think with the addon class like mentioned in previous answers, but this is what works for me:
<div class="form-group">
<div class="input-group input-group-lg">
<div class="input-group-prepend">
<span class="input-group-text"><i class="fa fa-user"></i></span>
</div>
<input type="text" class="form-control" placeholder="Username">
</div>
</div>
Here is a full form demonstration with 3 input fields:
<form>
<div class="form-group">
<div class="input-group input-group-lg">
<div class="input-group-prepend">
<span class="input-group-text"><i class="fa fa-user"></i></span>
</div>
<input type="text" class="form-control" placeholder="Name">
</div>
</div>
<div class="form-group">
<div class="input-group input-group-lg">
<div class="input-group-prepend">
<span class="input-group-text"><i class="fa fa-envelope"></i></span>
</div>
<input type="email" class="form-control" placeholder="Email">
</div>
</div>
<div class="form-group">
<div class="input-group input-group-lg">
<div class="input-group-prepend">
<span class="input-group-text"><i class="fa fa-pencil"></i></span>
</div>
<textarea class="form-control" placeholder="Message" rows="5"></textarea>
</div>
</div>
<input type="submit" value="Submit" class="btn btn-outline-info btn-block btn-lg">
</form>
... and the final result is:
You can use input-group-addon class like this:
<div class="form-group">
<label for="inputFirstName">First Name</label>
<div class="input-group">
<div class="input-group addon">
<span class="input-group-addon" id="basic-addon1"><i class="fa fa-user"></i></span>
<input type="text" class="form-control" id="inputFirstName">
</div>
</div>
</div>
<div class="form-group">
<label for="inputFirstName">First Name</label>
<div class="input-group">
<div class="input-group addon">
<input type="text" class="form-control" id="inputFirstName">
<span class="input-group-addon" id="basic-addon1"><i class="fa fa-user"></i></span>
</div>
</div>
</div>
CODEPEN
Your code is good, Bootstrap 4 does not expose this feature but it actually has class inside. All you need to do is just add the class "input-group-text" next to "input-group addon".
<div class="form-group">
<label for="inputFirstName">First Name</label>
<div class="input-group">
<div class="input-group addon input-group-text">
<i class="fa fa-user">
</i>
<input type="text" class="form-control" id="inputFirstName">
</div>
</div>
</div>
Maybe this will help you.
<div class="form-group">
<label for="inputFirstName">First Name</label>
<div class="input-group margin-bottom-sm">
<span class="input-group-addon"><i class="fa fa-user"></i></span>
<input class="form-control" type="text" id="inputFirstName">
</div>
</div>
Try putting the css link of font-awesome before the bootstrap link.
Related
I am using bootstrap 4, jQuery 3.3.1 and datepicker (http://www.eyecon.ro/bootstrap-datepicker/)
I have three issues:
The Calendar icon is not the size of the input box
When submit without selecting the date, bootstrap validation message not working.
Auto close is not working.
$(document).ready(function()
{
$('#depositeDate').datepicker({
"setDate": new Date(),
"autoclose": true
});
})
<div class="form-group row">
<label for="depositeDate" class="col-sm-4 col-form-label col-form-label-lg">Deposit Date</label>
<div class="col-sm-2 input-group date">
<input type="text" class=" text-input form-control" id ="depositeDate" placeholder="MM/DD/YYYY">
<div class="input-group-addon">
<i class="fas fa-calendar-alt fa-3x" style="color:RED"></i> </div>
<div class="invalid-feedback">
Please enter a valid Order Number.
</div>
</div>
</div>
The Calendar icon is not the size of the input box
The markup for input group addon is changed in Bootstrap 4.0 stable
<div class="input-group mb-3">
<input type="text" class="form-control" placeholder="Recipient's username" aria-label="Recipient's username" aria-describedby="basic-addon2">
<div class="input-group-append">
<span class="input-group-text" id="basic-addon2">#example.com</span>
</div>
</div>
Your code should be
<div class="input-group date" >
<input type="text" class="form-control" id ="depositeDate" placeholder="MM/DD/YYYY">
<div class="input-group-append">
<span class="input-group-text" id="basic-addon2"><span class="fa fa-calendar"></span></span>
</div>
</div>
3.Auto close is not working.
I don't see setting like "autoclose": true , we should explicitly call to close the datepicker.
.on('changeDate', function(ev) {
checkout.hide();
})
<div class="form-group row justify-content-center align-items-center">
<label for="depositeDate" class="col-sm-3 col-form-label">Deposit Date</label>
<div class="col-sm-3 input-group date" >
<input type="text" class="text-input form-control" id ="depositeDate" placeholder="MM/DD/YYYY">
<div class="input-group-addon" style="cursor: pointer;" onclick="$('#depositeDate').focus();">
<i class="fas fa-calendar-alt fa-2x"></i>
</div>
</div>
</div>
this code will do:
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/1.12.4/jquery.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/moment.js/2.15.1/moment.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/3.3.7/js/bootstrap.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-datetimepicker/4.7.14/js/bootstrap-datetimepicker.min.js"></script>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/3.3.7/css/bootstrap.min.css">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-datetimepicker/4.7.14/css/bootstrap-datetimepicker.min.css">
<br>
<div class="container">
<div class="row">
<div class='col-sm-6'>
<div class="form-group">
<label for="Order number">Order number</label>
<input type="text" id="Order number" >
</div>
<div class="form-group">
<div class='input-group date' id='datetimepicker1'>
<label for="male">Deposit Date</label>
<input type='text' class="form-control" />
<span class="input-group-addon">
<span class="glyphicon glyphicon-calendar"></span>
</span>
</div>
</div>
</div>
</div>
</div>
<script>$(function() {
$('#datetimepicker1').datetimepicker();
});</script>
check out the fiddle:https://jsfiddle.net/rqy7L2do/
Today I copied literally a test piece of code from the twitter-bootstrap site into my code. I tried to get a horizontal form like in the example. but for some reason, I don't get a horzontal layout. My site http://073design.nl/kasopmaak/?
Code i used for horizontal form:
<form class="form-horizontal">
<div class="control-group">
<label class="control-label" for="inputEmail">Email</label>
<div class="controls">
<input type="text" id="inputEmail" placeholder="Email">
</div>
</div>
<div class="control-group">
<label class="control-label" for="inputPassword">Password</label>
<div class="controls">
<input type="password" id="inputPassword" placeholder="Password">
</div>
</div>
<div class="control-group">
<div class="controls">
<label class="checkbox">
<input type="checkbox"> Remember me
</label>
<button type="submit" class="btn">Sign in</button>
</div>
</div>
</form>
Your code works fine only when link with bootstrap version 2.3 DEMO1
Check this works in bootstrap 3
<form class="form-horizontal">
<div class="form-group">
<label for="inputEmail" class="control-label col-xs-2">Email</label>
<div class="col-xs-10">
<input type="email" class="form-control" id="inputEmail" placeholder="Email">
</div>
</div>
<div class="form-group">
<label for="inputPassword" class="control-label col-xs-2">Password</label>
<div class="col-xs-10">
<input type="password" class="form-control" id="inputPassword" placeholder="Password">
</div>
</div>
<div class="form-group">
<div class="col-xs-offset-2 col-xs-10">
<div class="checkbox">
<label><input type="checkbox"> Remember me</label>
</div>
</div>
</div>
<div class="form-group">
<div class="col-xs-offset-2 col-xs-10">
<button type="submit" class="btn btn-primary">Login</button>
</div>
</div>
</form>
I'd like to create a long form that is just all one form instead of a bunch of separate forms. Is this doable? I've reviewed all the Bootstrap Documentation and this seems to be the only way to do it. Does anyone know a way around this? Below is what I have, every field is a separate form, and I need it to be one.
<div class="row-container">
<div class="row">
<div class="field-wrapper">
<form class="form-inline">
<div class="form-group">
<label for="claimnumber">Claim Number</label>
<input type="text" class="form-control" id="claimnumber" placeholder="">
</div>
</form>
</div>
<div class="field-wrapper">
<form class="form-inline">
<div class="form-group">
<label for="insuredid">Insured ID</label>
<input type="text" class="form-control" id="insuredid" placeholder="">
</div>
</form>
</div>
<div class="field-wrapper">
<form class="form-inline">
<div class="form-group">
<label for="claimnumber">Patient ID</label>
<input type="text" class="form-control" id="patientid" placeholder="">
</div>
</form>
</div>
<div class="field-wrapper">
<form class="form-inline">
<div class="form-group">
<label for="lastname">Patient Last Name</label>
<input type="text" class="form-control" id="lastname" placeholder="">
</div>
</form>
</div>
<div class="field-wrapper">
<form class="form-inline">
<div class="form-group">
<label for="lastname">Patient Last Name</label>
<input type="text" class="form-control" id="Text1" placeholder="">
</div>
</form>
</div>
</div>
</div>
<div class="datecontainer">
<div class="date1container">
<div class="dateheading">Service Date</div>
<div class="datebody">
<div class="field-wrapper">
<form class="form-inline">
<div class="form-group">
<label for="lastname">Start</label>
<input type="text" class="form-control calendar" id="date" placeholder="00/00/0000">
</div>
</form>
</div>
<div class="field-wrapper">
<form class="form-inline">
<div class="form-group">
<label for="lastname">End</label>
<input type="text" class="form-control calendar2" id="date2" placeholder="00/00/0000">
</div>
</form>
</div>
</div>
</div>
<div class="date2container">
<div class="dateheading">Import Date</div>
<div class="datebody">
<div class="field-wrapper">
<form class="form-inline">
<div class="form-group">
<label for="lastname">Start</label>
<input type="text" class="form-control calendar3" id="date3" placeholder="00/00/0000">
</div>
</form>
</div>
It works with just one form... check this
http://jsfiddle.net/7LChZ/1/show/
<div class="container">
<form class="form-inline">
<div class="row-container">
<div class="row">
<div class="field-wrapper">
<div class="form-group">
<label for="claimnumber">Claim Number</label>
<input type="text" class="form-control" id="claimnumber" placeholder="" />
</div>
</div>
<div class="field-wrapper">
<div class="form-group">
<label for="insuredid">Insured ID</label>
<input type="text" class="form-control" id="insuredid" placeholder="" />
</div>
</div>
<div class="field-wrapper">
<div class="form-group">
<label for="claimnumber">Patient ID</label>
<input type="text" class="form-control" id="patientid" placeholder="" />
</div>
</div>
<div class="field-wrapper">
<div class="form-group">
<label for="lastname">Patient Last Name</label>
<input type="text" class="form-control" id="lastname" placeholder="" />
</div>
</div>
<div class="field-wrapper">
<div class="form-group">
<label for="lastname">Patient Last Name</label>
<input type="text" class="form-control" id="Text1" placeholder="" />
</div>
</div>
</div>
</div>
<div class="datecontainer">
<div class="date1container">
<div class="dateheading">Service Date</div>
<div class="datebody">
<div class="field-wrapper">
<div class="form-group">
<label for="lastname">Start</label>
<input type="text" class="form-control calendar" id="date" placeholder="00/00/0000" />
</div>
</div>
<div class="field-wrapper">
<div class="form-group">
<label for="lastname">End</label>
<input type="text" class="form-control calendar2" id="date2" placeholder="00/00/0000" />
</div>
</div>
</div>
</div>
<div class="date2container">
<div class="dateheading">Import Date</div>
<div class="datebody">
<div class="field-wrapper">
<div class="form-group">
<label for="lastname">Start</label>
<input type="text" class="form-control calendar3" id="date3" placeholder="00/00/0000" />
</div>
</div>
</div>
</div>
</div>
</form>
</div>
What I change is, I remove all form tags and wrap them all with just one.
You should only use one <form> -tag and not multiple ones if you only need one form. You should place it after <div class="row">. And don't forget to close it correctly!
I'm trying to insert a new branch for distributor data to pass to Sinatra. It's able to insert a new record but this error is produced:
"ERROR Rack::Lint::LintError: body yielded non string value [:disBranchID, 27]"
disBranchID is the primary key of the table and it's set to auto increment.
The HTML looks like this:
<form name="add_dis_branch_form" action="/add_dis_branch" method="post" id="disB" enctype="multipart/form-data">
<div class="input-group">
<span class="input-group-addon"> Brand </span>
<select id="disSlcMan" class="btn btn-default full-width" name="disID" ng-model="disB.disID" required>
<option value="">Select Brand</option>
<% AutoMobile::DB[:distributor].select(:disID, :disComName).each do |dis| %>
<option value="<%= dis[:disID]%>"><%= dis[:disComName] %></option>
<% end %>
</select>
</div>
<br>
<div class="input-group">
<span class="input-group-addon"><i class="fa fa-map-marker"></i> Address</span>
<input type="text" class="form-control" name="address" placeholder="Address" required ng-model="disB.address" >
</div>
<br>
<div class="row">
<div class="col-lg-6 col-md-6">
<div class="input-group">
<span class="input-group-addon"> City </span>
<input type="text" class="form-control" name="city" placeholder="Petaling Jaya" required ng-model="disB.city">
</div>
</div>
<div class="col-lg-6 col-md-6">
<div class="input-group">
<span class="input-group-addon"> State </span>
<input type="text" class="form-control" name="state" placeholder="Selangor" required ng-model="disB.state">
</div>
</div>
</div>
<br>
<div class="row">
<div class="col-lg-6 col-md-6">
<div class="input-group">
<span class="input-group-addon"> Zip </span>
<input type="text" class="form-control" name="zip" placeholder="47800" required ng-model="disB.zip" ng-pattern="/^\d{5}$/">
</div>
<span ng-show="add_dis_branch_form.zip.$error.pattern" class="help-inline">Invalid zip code</span>
</div>
<div class="col-lg-6 col-md-6">
<div class="input-group">
<span class="input-group-addon" title="Map"><i class="fa fa-map-marker"></i></span>
<button id="btMap" class="btn btn-success form-control" onclick="return false;">Find Your Location</button>
</div>
</div>
</div>
<br>
<div class="row">
<div class="col-lg-6 col-md-6">
<div class="input-group">
<span class="input-group-addon"> Latitude </span>
<input type="text" class="form-control" id="disLat" name="latitude" required ng-model="disB.latitude" >
</div>
</div>
<div class="col-lg-6 col-md-6">
<div class="input-group">
<span class="input-group-addon"> Longitude </span>
<input type="text" class="form-control" id="disLong" name="longitude" required ng-model="disB.longitude" >
</div>
</div>
</div>
<small>
<b class="help-inline">
Click Find Your Location button to locate your address.
</b>
</small>
<br>
<div class="row">
<div class="col-lg-6 col-md-6">
<div class="input-group">
<span class="input-group-addon"><i class="fa fa-phone"></i> Phone</span>
<input type="text" class="form-control" name="phoneNo" placeholder="03-12345432" required ng-model="disB.phoneNo" ng-pattern="/^0[0-9]{1}-[0-9]{8}$/">
</div>
</div>
<div class="col-lg-6 col-md-6">
<div class="input-group">
<span class="input-group-addon"><i class="fa fa-print"></i> Fax </span>
<input type="text" class="form-control" name="faxNo" placeholder="03-12345432" required ng-model="disB.faxNo" ng-pattern="/^0[0-9]{1}-[0-9]{8}$/">
</div>
</div>
</div>
<br>
<div class="pull-right">
<input type="submit" class="btn btn-success" ng-disabled="!canSave('add_dis_branch_form')">
</div>
</form> <!-- end form -->
The Sinatra code:
add_dis_branch = lambda do
newBranch = AutoMobile::DisBranch.new
newBranch.address = params[:address]
newBranch.city = params[:city]
newBranch.state = params[:state]
newBranch.zip = params[:zip]
newBranch.phone = params[:phoneNo]
newBranch.fax = params[:faxNo]
newBranch.latitude = params[:latitude]
newBranch.longitude = params[:longitude]
newBranch.disID = params[:disID]
newBranch.save
end
Here is one way you could write the route:
post "/automobile/branch" do
newBranch = AutoMobile::DisBranch.new
newBranch.address = params[:address]
newBranch.city = params[:city]
newBranch.state = params[:state]
newBranch.zip = params[:zip]
newBranch.phone = params[:phoneNo]
newBranch.fax = params[:faxNo]
newBranch.latitude = params[:latitude]
newBranch.longitude = params[:longitude]
newBranch.disID = params[:disID]
newBranch.save
halt 201
end
but I suggest you take a good read of the documentation for Sinatra on creating routes and for Sequel on creating model instances.
I would like to design a two column horizontal form using Bootstrap V2.3.2. The following is the html:
<div id='content' class='row-fluid'>
<div class='span12 main'>
<h2>Product Data</h2>
<form class="form-horizontal">
<fieldset>
<div class="form-group">
<label for="inputAppName" class="control-label col-xs-2">Application Name </label>
<div class="col-xs-10">
<input type="text" class="form-control" id="app_name" name="app_name" placeholder="Application Name">
</div>
</div>
<div style="height:10px;"></div>
<div class="form-group">
<label for="inputAppDesc" class="control-label col-xs-2">Description </label>
<div class="col-xs-10">
<textarea class="form-control" id="app_desc" name="app_desc" rows="4" placeholder="Application Description"></textarea>
</div>
</div>
</fieldset>
</form>
</div>
</div>
I find that the width of the input-text and textarea on the second column are smaller. I would like to extend them to take up the rest space. I tried to use the "input-block-level" class but the input-text and textarea will then not be on the same row as the label.
Can anyone help?
Thanks in advance!
The first thing to do is to don't use the Bootstrap 3 class...
Try Bootstrap 2 instead... Replace col-xx-[1-12] by span[1-12]
Your code with input in span11 :
http://www.bootply.com/119374
<div id="content" class="row-fluid">
<div class="span12 main">
<h2>Product Data</h2>
<form class="form-horizontal">
<fieldset>
<div class="form-group row-fluid">
<label for="inputAppName" class="control-label span2">Application Name </label>
<div class="span10">
<input type="text" class="form-control span11" id="app_name" name="app_name" placeholder="Application Name">
</div>
</div>
<div style="height:10px;">
</div>
<div class="form-group row-fluid">
<label for="inputAppDesc" class="control-label span2">Description </label>
<div class="span10">
<textarea class="form-control span11" id="app_desc" name="app_desc" rows="4" placeholder="Application Description"></textarea>
</div>
</div>
</fieldset>
</form>
</div>
</div>
try this
<form>
<div class="row">
<div class="col-xs-6">
<div class="input-group">
<span class="input-group-addon">
<input type="checkbox">
</span>
<input type="text" class="form-control">
</div>
</div>
<div class="col-xs-6">
<div class="input-group">
<span class="input-group-addon">
<input type="radio">
</span>
<input type="text" class="form-control">
</div>
</div>
</div>
</form>