Bootstrap modal not showing in the expected way - html

I am using bootstrap and my modal won't show up the way it is supposed to, I have tried using the form that is inside the modal on the page, and there it shows up correctly but inside the modal, the form is also displayed as deformed, I have already tried solutions to similar questions here but they didn't work. The modal looks like this,
Expected to look something like this but without the footer:
The bootstrap code:
<!-- Modal -->
<div class="modal fade" id="exampleModal" tabindex="-1" role="dialog" aria-labelledby="exampleModalLabel" aria-hidden="true">
<div class="modal-dialog" role="document">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title" id="exampleModalLabel">Modal title</h5>
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
<span aria-hidden="true">×</span>
</button>
</div>
<div class="modal-body">
<div class="container">
<div>
<div class="styled-input wide">
<input type="email" id="email" required />
<label>Email</label>
</div>
</div>
<div>
<div class="styled-input wide">
<input type="number" id="phone" required />
<label>Phone Number</label>
</div>
</div>
<div>
<div class="styled-input wide">
<input type="number" id="monthlyTurnOver" required />
<label>Monthly Turnover</label>
</div>
</div>
<div>
<div class="styled-input wide">
<input type="text" id="purpose" value="B2B collection" required />
<label>Purpose</label>
</div>
</div>
<div class="col-md-12 d-flex justify-content-center">
<input class="enalo-small-btn" style="height: 2.4375rem; margin-bottom: .4rem;" type="submit" value="Submit" onclick="contactUs()">
</div>
</div>
</div>
</div>
</div>
</div>

I am not sure what I did differently but I copied code from the modal I had built earlier on the same site which made it appear a lot better, than I overrode some styles and now it's visible properly, Thank you for your help,
The new code:
<div class="modal fade" style="font-size: 14px;" id="exampleModal" tabindex="-1" aria-labelledby="exampleModalLabel"
aria-hidden="true">
<div class="modal-dialog d-flex justify-content-center" role="document">
<div class="modal-content px-2" style="max-width: 300px;" id="modal">
<div class="modal-header">
<h5 class="modal-title" id="exampleModalLabel">Modal title</h5>
<div class="ml-auto">
<button type="button" class="close" data-dismiss="modal" id="crossclose" aria-label="Close" style="width: 83px;
height: 50px;
margin-top: 0px;
border: none;">
<span aria-hidden="true">×</span>
</button>
</div>
</div>
<div class="modal-body">
<div class="container">
<div>
<div class="styled-input wide">
<input placeholder="Email" type="email" id="email" required />
</div>
</div>
<div>
<div class="styled-input wide">
<input placeholder="Phone Number" type="number" id="phone" required />
</div>
</div>
<div>
<div class="styled-input wide">
<input placeholder="Monthly Turnover" type="number" id="monthlyTurnOver" required />
</div>
</div>
<div>
<div class="styled-input wide">
<input placeholder="Purpose" type="text" id="purpose" value="B2B collection" required />
</div>
</div>
<div class="col-md-12 d-flex justify-content-center">
<button class="enalo-small-btn" style="height: 2.4375rem; margin-bottom: .4rem;" type="submit" onclick="contactUs()">Submit</button>
</div>
</div>
</div>
</div>
</div>
</div>
Looks like this:

Related

Bootstrap Modal: Unable to align my text beside the boxes

I tried to make a modal form using bootstrap (horizontal form) and the field are shown under the labels. Any idea how can I fix it so the input text boxes will be at the right of the labels and not under them?
I've been trying all day to get it aligned with the boxes but to no avail. Pls help.
<button type="button" class="btn btn-primary" data-toggle="modal" data-target="#exampleModal" data-whatever="#mdo">Update Staff</button>
<div class="modal fade bd-example-modal-lg" id="exampleModal" tabindex="-1" role="dialog" aria-labelledby="exampleModalLabel" aria-hidden="true">
<div class="modal-dialog modal-lg" role="document">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title" id="exampleModalLabel">New message</h5>
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
<span aria-hidden="true">×</span>
</button>
</div>
<div class="modal-body form-horizontal">
<form class="form-horizontal" id="step2">
<div class="form-group">
<label for="name" class="col-sm-2 control-label" >Name</label>
<div class="col-sm-10">
<input id="name" class="form-control" type="text" placeholder="Enter Your Full Name" />
</div>
</div>
<div class="form-group">
<label for="email" class="col-sm-2 control-label">Email-Id</label>
<div class="col-sm-10">
<input id="email" class="form-control" type="email" placeholder="Enter Your Email-Id" />
</div>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-secondary" data-dismiss="modal">Close</button>
<button type="Submit" class="btn btn-primary">Done</button>
</div>
</form>
</div>
</div>
</div>
</div>
<div class="form-group d-flex align-items-baseline">
you can add them to the form-group class.
Also, label and input have to be inline-block to come together. the form-control class in bootstrap makes the display block of the given element. also you can use this. here I just added the form-group row class :
<div class="form-group row"> // just added the row class
<label for="name" class="col-sm-2 control-label" >Name</label>
<div class="col-sm-10">
<input id="name" class="form-control" type="text" placeholder="Enter Your Full Name" />
</div>
</div>
Try the following code. it will work for you. You haven't inserted the row class in order to get the two fields in the same line and you will need to you col-md classes in order to fit your message box in medium-size screens. You can use flex-box classes in order to center the text as bellow.
<button type="button" class="btn btn-primary" data-toggle="modal" data-target="#exampleModal" data-whatever="#mdo">Update Staff</button>
<div
class="modal fade bd-example-modal-lg"
id="exampleModal"
tabindex="-1"
role="dialog"
aria-labelledby="exampleModalLabel"
aria-hidden="true"
>
<div class="modal-dialog modal-lg" role="document">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title" id="exampleModalLabel">New message</h5>
<button
type="button"
class="close"
data-dismiss="modal"
aria-label="Close"
>
<span aria-hidden="true">×</span>
</button>
</div>
<div class="modal-body form-horizontal">
<form class="form-horizontal" id="step2">
<div class="form-group row">
<label
for="name"
class="col-sm-2 control-label d-flex align-items-center justify-content-center"
>Name</label
>
<div class="col-sm-10">
<input
id="name"
class="form-control"
type="text"
placeholder="Enter Your Full Name"
/>
</div>
</div>
<div class="form-group row">
<label
for="email"
class="col-sm-2 control-label d-flex align-items-center justify-content-center"
>Email-Id</label
>
<div class="col-sm-10">
<input
id="email"
class="form-control"
type="email"
placeholder="Enter Your Email-Id"
/>
</div>
</div>
<div class="modal-footer">
<button
type="button"
class="btn btn-secondary mr-2"
data-dismiss="modal"
>
Close
</button>
<button type="Submit" class="btn btn-primary">Done</button>
</div>
</form>
</div>
</div>
</div>
</div>

Input text fields becomes readonly in mobile view

I'm having problem with my code because in mobile view the input text fields doesn't have readonly attribute but when I open it in mobile view the fields becomes readonly. Here is the code:
<div class="modal fade" id="modal-transaction" tabindex="-1" role="dialog" aria-labelledby="exampleModalLabel1">
<div class="modal-dialog" role="document">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">×</span></button>
<h4 class="modal-title" id="exampleModalLabel1">Pay</h4>
</div>
<div class="modal-body block5">
<form method="post" id="myLevel">
<div class="form-body">
<div class="row">
<div class="col-sm-12 col-xs-12 col-lg-12">
<div class="form-group">
<label class="control-label">Amount to Pay</label>
<p class="text-danger">You'll be charge 5% of every Credit/Debit Card/E-Wallets Transaction. </p>
<input type="number" name="payment" class="form-control" id="payment" placeholder="Amount to Pay" data-error="Required!" required/>
<div class="help-block with-errors"></div>
</div>
</div>
</div>
</div>
<div class="form-actions">
<button type="button" id="save-transaction" class="btn btn-success"> <i class="fa fa-check"></i> Pay</button>
</div>
</form>
</div>
</div>
</div>

Element with name not being sent with form data via POST

I am trying to submit my modal title as post data, however it isn't being sent.
I have given the element a name attribute. Elements in the modal body are submitting as I would expect. Trying to submit the element whose name is "editModalTitle" below
HTML:
<div class="modal fade" id="editModal" tabindex="-1" role="dialog" aria-labelledby="editModal" aria-hidden="true">
<div class="modal-dialog" role="document">
<form action="/editItem" method="post" id ="editModalForm">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title" name="eModalTitle"></h5>
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
<span aria-hidden="true">×</span>
</button>
</div>
<div class="modal-body">
<div class="form-group">
<label>Quantity:</label>
<div class="row">
<div class="col">
<select class="form-control" id="qtSelect">
<option>Set to</option>
<option>Add</option>
<option>Subtract</option>
</select>
</div>
<div class="col" id= "qtD">
<input type="text" class="form-control" id="qt" name="quantityTB" placeholder="Quantity">
</div>
</div>
</div>
<div class="form-group" id="prD">
<label>Price:</label>
<input type="text" class="form-control" id="pr" name="priceTB" placeholder="Enter new price here...">
</div>
<div class="form-group">
<label>Notes:</label>
<div class="row">
<div class="col">
<select class="form-control" id="ntSelect">
<option>Set notes to:</option>
<option>Add to notes:</option>
</select>
</div>
<div class="col">
<input type="text" class="form-control" id="ntInput" name="notesTB"placeholder="Enter notes here...">
</div>
</div>
</div>
<div class="form-group">
<label>Location:</label>
<input type="text" class="form-control" id="loc" name="locationTB" placeholder="Enter new location here...">
</div>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-secondary" data-dismiss="modal">Close</button>
<button type="submit" id="eSvBtn" class="btn btn-primary">Save changes</button>
</div>
</form>
</div>
</div>
</div>
</div>
Form data here
Edit 1: Added full html for modal.
<div class="modal fade" id="editModal" tabindex="-1" role="dialog" aria-labelledby="editModal" aria-hidden="true">
<div class="modal-dialog" role="document">
<form action="/editItem" method="post" id ="editModalForm">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title" name="eModalTitle"></h5>
<!-- hidden value for modal title to post -->
<input type="hidden" id="Modal_title_to_post" name="Modal_title_to_post" value="eModalTitle">
<!-- hidden value for modal title to post -->
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
<span aria-hidden="true">×</span>
</button>
</div>
<div class="modal-body">
<div class="form-group">
<label>Quantity:</label>
<div class="row">
<div class="col">
<select class="form-control" id="qtSelect">
<option>Set to</option>
<option>Add</option>
<option>Subtract</option>
</select>
</div>
<div class="col" id= "qtD">
<input type="text" class="form-control" id="qt" name="quantityTB" placeholder="Quantity">
</div>
</div>
</div>
<div class="form-group" id="prD">
<label>Price:</label>
<input type="text" class="form-control" id="pr" name="priceTB" placeholder="Enter new price here...">
</div>
<div class="form-group">
<label>Notes:</label>
<div class="row">
<div class="col">
<select class="form-control" id="ntSelect">
<option>Set notes to:</option>
<option>Add to notes:</option>
</select>
</div>
<div class="col">
<input type="text" class="form-control" id="ntInput" name="notesTB"placeholder="Enter notes here...">
</div>
</div>
</div>
<div class="form-group">
<label>Location:</label>
<input type="text" class="form-control" id="loc" name="locationTB" placeholder="Enter new location here...">
</div>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-secondary" data-dismiss="modal">Close</button>
<button type="submit" id="eSvBtn" class="btn btn-primary">Save changes</button>
</div>
</div>
</form>
</div>
</div>
Updated code with hidden value for the modal title :)

CSS not working in ASP.NET Boilerplate

I'm trying to implement the same CSS for an input of type text as similar to the one we have in CreateUser default page. So when you click on User Name textbox it shows a blue line under it. Same I tried on my page it works fine, but when I go to other page and come to this page again, it does not show the blue line under the textbox.
create-user.component
<div bsModal #createUserModal="bs-modal" class="modal fade" (onShown)="onShown()" tabindex="-1" role="dialog" aria-labelledby="createUserModal" aria-hidden="true" [config]="{backdrop: 'static'}">
<div class="modal-dialog">
<div #modalContent class="modal-content">
<form *ngIf="active" #createUserForm="ngForm" id="frm_create_user" novalidate (ngSubmit)="save()">
<div class="modal-header">
<button type="button" class="close" (click)="close()" aria-label="Close">
<span aria-hidden="true">×</span>
</button>
<h4 class="modal-title">
<span>{{l("CreateNewUser")}}</span>
</h4>
</div>
<div class="modal-body">
<ul class="nav nav-tabs tab-nav-right" role="tablist">
<li role="presentation" class="active">User Details</li>
<li role="presentation">User Roles</li>
</ul>
<div class="tab-content">
<div role="tabpanel" class="tab-pane animated fadeIn active" id="user-details">
<div class="row clearfix" style="margin-top:10px;">
<div class="col-sm-12">
<div class="form-group form-float">
<div class="form-line">
<input id="username" type="text" name="UserName" [(ngModel)]="user.userName" required maxlength="32" minlength="2" class="validate form-control">
<label for="username" class="form-label">{{l("UserName")}}</label>
</div>
</div>
</div>
</div>
mypage.html
<div class="row clearfix" [#routerTransition]>
<div class="col-lg-12 col-md-12 col-sm-12 col-xs-12">
<div class="card main-content">
<div class="row" style="background-color:white;">
<div class="header">
<h2>
{{l('MyPage: ADD/EDIT')}}
</h2>
</div>
<br />
<form *ngIf="active" #myForm="ngForm" id="frm_create_store" novalidate (ngSubmit)="onSubmitBtnClick(myForm)">
<div class="col-md-12">
<div class="form-group form-float">
<label for="myName" class="form-label">{{l("myName")}}</label>
<div class="form-line">
<input id="myName" type="text" name="myName" [(ngModel)]="name.myName" placeholder="{{l('EnterNAME')}}" required maxlength="32" class="validate form-control">
</div>
</div>
</div>
I think you need to label with form="myName" inside the div which has class="form-line".
Instead of;
<label for="myName" class="form-label">{{l("myName")}}</label>
<div class="form-line">
<input id="myName" type="text" name="myName" [(ngModel)]="name.myName" placeholder="{{l('EnterNAME')}}" required maxlength="32" class="validate form-control">
</div>
Try this;
<div class="form-line">
<label for="myName" class="form-label">{{l("myName")}}</label>
<input id="myName" type="text" name="myName" [(ngModel)]="name.myName" placeholder="{{l('EnterNAME')}}" required maxlength="32" class="validate form-control">
</div>

Bootstrap: Modal with horizontal form and input addon does not layout properly

Rows with inputs seam wider then other rows (example is a button).
http://jsfiddle.net/ujnw8x4p/2/
<script src="http://netdna.bootstrapcdn.com/bootstrap/3.0.3/js/bootstrap.min.js"></script>
<link href="http://netdna.bootstrapcdn.com/bootstrap/3.0.3/css/bootstrap.min.css" rel="stylesheet"/>
<body>
<div class="container">
<div tabindex="-1" role="dialog" class="modal" size="lg" index="0" style="z-index: 1050; display: block;">
<div class="modal-dialog modal-lg">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close"><span aria-hidden="true">×</span></button>
<h3 class="modal-title">Bootstrap Modal with horizontal form and input addon</h3>
</div>
<div class="modal-body ng-scope">
<form class="form-horizontal" role="form">
<div class="form-group">
<label for="inputLinkPp" class="hidden-xs col-sm-3 control-label">Website</label>
<div class="input-group col-sm-9 xs-margin">
<span class="input-group-addon"><i class="glyphicon glyphicon-home"></i></span>
<input type="text" class="form-control" id="inputLinkPp" placeholder="link to your page"/>
</div>
</div>
<div class="form-group">
<p class="col-sm-offset-3 col-sm-9" style="text-align: right">
<button type="button" class="btn btn-success">
<i class="glyphicon glyphicon-link"></i> Create</button>
</p>
</div>
</form>
</div>
</div>
</div>
</div>
</div>
</body>
It seams like the modals padding is not respected by the input-group-addon.
But maybe i am not supposed to us input-groups in horizontal forms?
Any ideas on it?
I came up with this using only the Bootstrap classes. It looks like it accomplishes what you need, the only issue is the vertical alignment on the <label> doesn't match up with the <input>. Would need some custom css to override that. Here's the code:
<div class="container">
<div tabindex="-1" role="dialog" class="modal" size="lg" index="0" style="z-index: 1050; display: block;">
<div class="modal-dialog modal-lg">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close"><span aria-hidden="true">×</span></button>
<h3 class="modal-title">Bootstrap Modal with horizontal form and input addon</h3>
</div>
<div class="modal-body ng-scope">
<div class="row">
<div class="col-xs-2 text-right" >
<label>Website</label>
</div>
<div class="col-xs-10">
<div class="input-group">
<span class="input-group-addon"><i class="glyphicon glyphicon-home"></i></span>
<input type="text" class="form-control" id="inputLinkPp" placeholder="link to your page"/>
</div>
</div>
</div>
<br/>
<div class="row">
<div class="col-xs-12 text-right">
<div class="form-group">
<button type="button" class="btn btn-success">
<i class="glyphicon glyphicon-link"></i> Create</button>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
Oh and I accidentally removed the <form> tag from it, so that would need to be added back in. Here's a link to the Bootply:
Bootply
Hope that helps!
Finally i found a working solution.
Not sure though whether its the correct way or not.
Added this in my style sheet:
.form-horizontal .input-group {
padding-left: 15px;
padding-right: 15px;
}
http://jsfiddle.net/ujnw8x4p/3/