Bootstrap Validation Message Shows Up In The Wrong Place - asp.net

I have created an ASP.NET user input form using Bootstrap with the following HTML fragment:
<div class="row">
<div class="col-sm-8 col-sm-offset-2">
<asp:UpdatePanel ID="updSignIn" runat="server">
<ContentTemplate>
<div class="panel panel-default">
<div class="panel-heading">
Set Up Your Member Account
</div>
<div class="panel-body">
<div class="form-horizontal" role="form">
<div class="form-group">
<label for="ddSalutation" class="col-sm-4 control-label">
How Do We Greet You?
</label>
<div class="col-sm-2">
<asp:DropDownList ID="ddSalutation" runat="server" CssClass="form-control" />
</div>
</div>
<div class="form-group">
<label for="tbFirstName" class="col-sm-4 control-label">
First Name:
</label>
<div class="col-sm-5">
<input type="text" runat="server" class="form-control" id="tbFirstName"
required placeholder="Enter your first name">
</div>
</div>
<div class="form-group">
<label for="tbMiddleName" class="col-sm-4 control-label">
Middle Name/Initial:
</label>
<div class="col-sm-5">
<input type="text" runat="server" class="form-control" id="tbMiddleName"
required placeholder="Enter your middle name/initial">
</div>
</div>
<div class="form-group">
<label for="tbLastName" class="col-sm-4 control-label">
Last Name:
</label>
<div class="col-sm-5">
<input type="text" runat="server" class="form-control" id="tbLastName"
required placeholder="Enter your last name">
</div>
</div>
<div class="form-group">
<label for="tbPhone" class="col-sm-4 control-label">
Contact Telephone:
</label>
<div class="col-sm-3">
<input type="tel" title="Telephone Number" pattern="^\d{3}-\d{3}-\d{4}$"
id="tbPhone" placeholder="Telephone" class="form-control"
required runat="server" />
</div>
</div>
<div class="form-group">
<label for="tbSSN" class="col-sm-4 control-label">
SSN/Tax ID Number:
</label>
<div class="col-sm-3">
<input type="text" pattern="^\d{3}-\d{2}-\d{4}$"
title="Social Security Number" runat="server" class="form-control" id="tbSSN"
required placeholder="SSN/Tax ID">
</div>
</div>
<div class="spacer"> </div>
<div class="form-group">
<div class="col-sm-offset-4 col-sm-7" id="buttons">
<asp:Button ID="btnNext" runat="Server"
Text="Next"
CssClass="btn btn-default btn-sm col-sm-4"
OnClick="btnNext_Click"></asp:Button>
<button type="reset" id="btnReset" class="btn btn-default btn-sm col-sm-4">
Reset Form</button>
</div>
</div>
<div class="row">
<div class="spacer"> </div>
</div>
</div>
</div>
</div>
<div class="row">
<div class="text-center" id="divProcessing" style="display: none;">
<img src="images\loading.gif" style="height: 40px; width: 40px;" /> Please wait...
</div>
<div class="row">
<div class="alert alert-danger fade col-sm-offset-1 col-sm-10 text-center" id="lblStatus"> </div>
</div>
</div>
</ContentTemplate>
</asp:UpdatePanel>
</div>
</div>
The form lays out just fine. The problem is, when I click the button to process the form, the validation messages from Bootstrap don't line up with the fields that need attention from the user. Here's a screenshot of what happens:
As you can see, the form field that needs attention is the first name field, but the tooltip popup from Bootstrap is down to the lower right. I don't have any malformed HTML, so I don't understand what the problem is with the positioning of the popup message. Any help on this? Thanks!

Related

How to place lines between columns using bootstrap

How to place lines between columns. This is the below code i am working on but still not working. is there any way we can add separator? i added the screen shot what i am expecting.
HTML Code:
<div class="jumbotron jumbotron-fluid controls">
<div class="container">
<form class="form-form-submit">
<div class="row">
<div class="col">
<div class="form-group">
<label for="form_name">Name *</label>
<input id="form_name" type="text" name="surname" class="form-control" placeholder="Please enter your name *"
required="required" data-error="name is required.">
<div class="help-block with-errors"></div>
</div>
</div>
<div class="col">
<div class="form-group">
<label for="form_email">Email *</label>
<input id="form_email" type="email" name="email" class="form-control"
placeholder="Please enter your email *" required="required" data-error="Valid email is required.">
</div>
</div>
<div class="w-100"></div>
<div class="col">
<div class="form-group">
<label for="form_phone">Phone</label>
<input id="form_phone" type="tel" name="phone" class="form-control"
placeholder="Please enter your phone number">
<div class="help-block with-errors"></div>
</div>
</div>
<div class="col">
<div class="btn-group" style="padding-top: 25px;">
<input type="submit" class="btn btn-primary" value="Submit">
</div>
</div>
</div>
</form>
</div>
Expecting to place this code to show lines:
<div class="col-md-2 col-sm-4">
<div class="line">|</div>
<div>OR</div>
<div class="line">|</div>
</div>
I want output like this.
|
Name | Email
OR
Phone Button |
|
I'm not sure if this is what you're trying to do.
.v-line {
width: 5px;
background-color: teal;
}
.or {
background-color: #e9ecef;
}
<link href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css" rel="stylesheet"/>
<div class="jumbotron jumbotron-fluid controls">
<div class="container">
<form class="form-form-submit">
<div class="d-flex flex-row">
<div class="d-inline-block w-50">
<div class="col">
<div class="form-group">
<label for="form_name">Name *</label>
<input id="form_name" type="text" name="surname" class="form-control" placeholder="Please enter your name *"
required="required" data-error="name is required.">
<div class="help-block with-errors"></div>
</div>
</div>
<div class="col">
<div class="form-group">
<label for="form_phone">Phone</label>
<input id="form_phone" type="tel" name="phone" class="form-control"
placeholder="Please enter your phone number">
<div class="help-block with-errors"></div>
</div>
</div>
</div>
<div class="v-line d-flex align-items-center justify-content-center">
<span class="or">OR</span>
</div>
<div class="d-inline-block w-50">
<div class="col">
<div class="form-group">
<label for="form_email">Email *</label>
<input id="form_email" type="email" name="email" class="form-control"
placeholder="Please enter your email *" required="required" data-error="Valid email is required.">
</div>
</div>
<div class="col">
<div class="btn-group" style="padding-top: 25px;">
<input type="submit" class="btn btn-primary" value="Submit">
</div>
</div>
</div>
</div>
</form>
</div>
You can shrink the fields by one col unit, so that both the left and right fields are col-md-5. This will give them a total column span of 10, leaving 2 spare (as Bootstrap columns always total 12).
From here, you can add offset-md-2 to the right-most columns to create a gap composed of 2 columns:
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css" integrity="sha384-Gn5384xqQ1aoWXA+058RXPxPg6fy4IWvTNh0E263XmFcJlSAwiGgFAW/dAiS6JXm" crossorigin="anonymous">
<script src="https://code.jquery.com/jquery-3.2.1.slim.min.js" integrity="sha384-KJ3o2DKtIkvYIK3UENzmM7KCkRr/rE9/Qpg6aAZGJwFDMVNA/GpGFF93hXpG5KkN" crossorigin="anonymous"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.12.9/umd/popper.min.js" integrity="sha384-ApNbgh9B+Y1QKtv3Rn7W3mgPxhU9K/ScQsAP7hUibX39j7fakFPskvXusvfa0b4Q" crossorigin="anonymous"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/js/bootstrap.min.js" integrity="sha384-JZR6Spejh4U02d8jOt6vLEHfe/JQGiRRSQQxSfFWpi1MquVdAyjUar5+76PVCmYl" crossorigin="anonymous"></script>
<div class="jumbotron jumbotron-fluid controls">
<div class="container">
<form class="form-form-submit">
<div class="row">
<div class="col-md-5">
<div class="form-group">
<label for="form_name">Name *</label>
<input id="form_name" type="text" name="surname" class="form-control" placeholder="Please enter your name *" required="required" data-error="name is required.">
<div class="help-block with-errors"></div>
</div>
</div>
<div class="col-md-5 offset-md-2">
<div class="form-group">
<label for="form_email">Email *</label>
<input id="form_email" type="email" name="email" class="form-control" placeholder="Please enter your email *" required="required" data-error="Valid email is required.">
</div>
</div>
<div class="w-100"></div>
<div class="col-md-5">
<div class="form-group">
<label for="form_phone">Phone</label>
<input id="form_phone" type="tel" name="phone" class="form-control" placeholder="Please enter your phone number">
<div class="help-block with-errors"></div>
</div>
</div>
<div class="col-md-5 offset-md-2">
<div class="btn-group" style="padding-top: 25px;">
<input type="submit" class="btn btn-primary" value="Submit">
</div>
</div>
</div>
</form>
</div>
Note that you cannot (easily) make the gap comprise of only 1 unit while keeping both columns the same length (as the total column count is even). However, you can make use of any combination of column + offset + column that totals twelve. For example, col-md-5 + offset-md-1 + col-md-6.
I know there is a better way to do this but right now this is I can remember. Basically, just create an empty col div in between the two columns:
<div class="jumbotron jumbotron-fluid controls">
<div class="container">
<form class="form-form-submit">
<div class="row">
<div class="col-5"`enter code here`>
<div class="form-group">
<label for="form_name">Name *</label>
<input id="form_name" type="text" name="surname" class="form-control" placeholder="Please enter your name *"
required="required" data-error="name is required.">
<div class="help-block with-errors"></div>
</div>
</div>
<div class="col-1">
</div>
<div class="col-6">
<div class="form-group">
<label for="form_email">Email *</label>
<input id="form_email" type="email" name="email" class="form-control"
placeholder="Please enter your email *" required="required" data-error="Valid email is required.">
</div>
</div>
<div class="w-100"></div>
<div class="col-5">
<div class="form-group">
<label for="form_phone">Phone</label>
<input id="form_phone" type="tel" name="phone" class="form-control"
placeholder="Please enter your phone number">
<div class="help-block with-errors"></div>
</div>
</div>
<div class="col-1">
</div>
<div class="col-6">
<div class="btn-group" style="padding-top: 25px;">
<input type="submit" class="btn btn-primary" value="Submit">
</div>
</div>
</div>
</form>
</div>

CSS Bootstrap 3.0 field with icon

I have a form with 3 fields, two of them are for entering dates. I was requested to add an icon to the very end of the field.
This is the result:
If you see the field that has the icon expands beyonds the other fields to the left and right so it looks pretty ugly.
This is the code:
<div class="form-horizontal">
<div class="form-group">
<label class="col-md-4 control-label">Begin</label>
<div class="col-md-8">
<input type="text" class="form-control" placeholder="mm/dd/yyyy" />
</div>
</div>
<div class="form-group">
<label class="col-md-4 control-label">End</label>
<div class="input-group col-md-8">
<input type="text" class="form-control" placeholder="mm/dd/yyyy" />
<span class="input-group-addon"><i class="fa fa-lock"></i></span>
</div>
</div>
<div class="form-group">
<label class="col-md-4 control-label">Text Search</label>
<div class="col-md-5">
<input type="text" class="form-control">
</div>
<div class="col-md-3">
<button id="btnSavedMessages" class="btn btn-primary">Search</button>
</div>
</div>
</div>
Any clue on how to do it right?
Here is your fixed code please copy it and paste it
<div class="form-horizontal">
<div class="form-group">
<label class="col-md-4 control-label">Begin</label>
<div class="col-md-8">
<input type="text" class="form-control" placeholder="mm/dd/yyyy">
</div>
</div>
<div class="form-group">
<label class="col-md-4 control-label">End</label>
<div class="col-md-8">
<div class="input-group ">
<input type="text" class="form-control" placeholder="mm/dd/yyyy">
<span class="input-group-addon"><i class="fa fa-lock"></i></span>
</div></div>
</div><div class="form-group">
<label class="col-md-4 control-label">Text Search</label>
<div class="col-md-5">
<input type="text" class="form-control">
</div>
<div class="col-md-3">
<button id="btnSavedMessages" class="btn btn-primary">Search</button></div></div></div>
I have tested it works fine. Cheers!
Some CSS is messing with you.
Your line with input-group col-md-8 is apparently malfunctioning.
I made an example:
https://plnkr.co/edit/gxpaP4wR8cZzb3E4CvtR
Check if you have some custom CSS that is overriding bootstraps'.
Use my code this is working fine.
<!-- Latest compiled and minified CSS -->
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u" crossorigin="anonymous">
<div class="form-horizontal">
<div class="form-group">
<label class="col-md-4 control-label">Begin</label>
<div class="col-md-8">
<input type="text" class="form-control" placeholder="mm/dd/yyyy" />
</div>
</div>
<div class="form-group">
<label class="col-md-4 control-label">End</label>
<div class="col-md-8">
<div class="input-group">
<input type="text" class="form-control" placeholder="mm/dd/yyyy" />
<span class="input-group-addon"><i class="fa fa-lock"></i></span>
</div>
</div>
</div>
<div class="form-group">
<label class="col-md-4 control-label">Text Search</label>
<div class="col-md-5">
<input type="text" class="form-control">
</div>
<div class="col-md-3">
<button id="btnSavedMessages" class="btn btn-primary">Search</button>
</div>
</div>
</div>

How to center form controls with Bootstrap

What am I missing?
I can see the border of the container and it correctly shows the area that I have to work with.
However when I add the row (div) and offset(div) it is left justifying it.
<div id="page" class="container" style="border:solid">
<div class="row">
<div class="col-md-6 col-md-offset-3">
<div class="form-group">
<label for="firstName">First Name:</label>
<input type="text" id="firstName" class="form-control" />
</div>
<div class="form-group">
<label for="lastName">Last Name:</label>
<input type="text" id="lastName" class="form-control" />
</div>
</div>
</div>
</div>
I think I know what you are meaning, but I'm not sure. Do you mean like this?
If so, the class for that is:
class="text-center"
So you can change your code to this:
<div id="page" class="container" style="border:solid">
<div class="row">
<div class="col-md-6 col-md-offset-3 text-center">
<div class="form-group">
<label for="firstName">First Name:</label>
<input id="firstName" class="form-control text-center" type="text">
</div>
<div class="form-group">
<label for="lastName">Last Name:</label>
<input id="lastName" class="form-control text-center" type="text">
</div>
</div>
</div>
Or you can add it to just the controls you want, for example just the input form controls.
Hope that helps!
Bootstrap can provide a great mobile experience, but desktops can also benefit from its scaffolding capabilities. So, when I develop forms I like to use the least amount of space possible. With that in mind I have improved on Demonic Penguin's code and your, as well. Like so:
<div id="page" class="container" style="border:solid">
<div class="row" style="padding-top: 12px;"></div>
<div class="row">
<div class="col-md-6 col-md-offset-3 text-center">
<div class="form-group">
<input id="firstName" class="form-control text-center" placeholder="First Name" type="text">
</div>
<div class="form-group">
<input id="lastName" class="form-control text-center" placeholder="Last Name" type="text">
</div>
</div>
</div>
</div>
You can also embellish your form by adding icons to the fields, like so:
<div id="page" class="container" style="border:solid">
<div class="row" style="padding-top: 12px;"></div>
<div class="row">
<div class="col-md-6 col-md-offset-3 text-center">
<div class="form-group">
<div class="input-group">
<span class="input-group-addon" id="firstName-addon"><i class="fa fa-user"></i></span>
<input id="firstName" class="form-control text-center" placeholder="First Name" type="text">
</div>
</div>
<div class="form-group">
<div class="input-group">
<span class="input-group-addon" id="lastName-addon"><i class="fa fa-user"></i></span>
<input id="lastName" class="form-control text-center" placeholder="Last Name" type="text">
</div>
</div>
</div>
</div>
</div>
For this implementation, you must add a FontAwesome CSS reference link to your page(s) that you can get from here: https://www.bootstrapcdn.com/fontawesome/

Bootstrap input-group button is right aligned

How can I align the search button to be next to the search box?
Code is
<div class="form-group">
<label class="col-lg-2 control-label" for="inputLoginSearch">Search for HOA</label>
<div class="col-lg-10">
<div class="input-group">
<input id="inputLoginSearch" class="form-control" type="text" placeholder="Enter search phrase">
<span class="input-group-btn">
<button class="btn btn-info" type="button">Search</button>
</span>
</div>
</div>
</div>
Edit - added full markup of page
<div id="mainDiv" runat="server" class="panel-body">
<asp:UpdatePanel ID="UpdatePanel1" runat="server" UpdateMode="Conditional" ChildrenAsTriggers="false">
<ContentTemplate>
<div class="panel-group" id="accordion">
<div class="panel panel-default">
<div class="panel-heading">
<h4 class="panel-title">
<a data-toggle="collapse" data-parent="#accordion" href="#collapseOne">Standard Login</a>
</h4>
</div>
<div id="collapseOne" class="panel-collapse collapse in">
<div class="panel-body">
<%-- Start of Standard Login--%>
<asp:UpdatePanel ID="UpdatePanel2" runat="server">
<ContentTemplate>
<div id="StandardLoginForm" role="form" class="form-horizontal">
<fieldset>
<div class="form-group">
<label class="col-lg-2 control-label" for="inputLoginSearch">Search for HOA</label>
<div class="col-lg-10">
<div class="input-group">
<input id="inputLoginSearch" class="form-control" type="text" placeholder="Enter search phrase">
<span class="input-group-btn" >
<button class="btn btn-info" type="button">Search</button>
</span>
</div>
</div>
</div>
<div class="form-group">
<label class="col-lg-2 control-label" for="select">HOA</label>
<div class="col-lg-10">
<select class="form-control" id="select">
<option>1</option>
<option>2</option>
<option>3</option>
<option>4</option>
<option>5</option>
</select>
</div>
</div>
<div class="form-group">
<label class="col-lg-2 control-label" for="inputUserName">User Name</label>
<div class="col-lg-10">
<input class="form-control" id="inputUserName" type="text" placeholder="User Name">
</div>
</div>
<div class="form-group">
<label class="col-lg-2 control-label" for="inputPassword">Password</label>
<div class="col-lg-10">
<input class="form-control" id="inputPassword" type="password" placeholder="Password">
</div>
</div>
<div class="form-group">
<div class="col-lg-10 col-lg-offset-2">
<button class="btn btn-primary" type="submit">Login</button>
</div>
</div>
</fieldset>
</div>
</ContentTemplate>
</asp:UpdatePanel>
<%--End of Standard Login--%>
</div>
</div>
</div>
<div class="panel panel-default">
<div class="panel-heading">
<h4 class="panel-title">
<a data-toggle="collapse" data-parent="#accordion" href="#collapseTwo">HOA Manager Integrated Login</a>
</h4>
</div>
<div id="collapseTwo" class="panel-collapse collapse">
<div class="panel-body">
<%-- Start of Standard Login--%>
<asp:UpdatePanel ID="UpdatePanel3" runat="server">
<ContentTemplate>
</ContentTemplate>
</asp:UpdatePanel>
<%--End of Standard Login--%>
</div>
</div>
</div>
</div>
</ContentTemplate>
</asp:UpdatePanel>
</div>
If I create a brand new 'out of the box' WebForms project in VS2013 the same thing happens. Also form-vertical makes a complete mess of everything, only form-horizontal works.
DavidG was right about the issue - the problem was removing the max-width for inputs made them spread right across the entire page - so the workaround I found was to leave the max-width in, and just change the input-group div to a max-width (allowing for the button) and then setting in the input at width:100%;
This seems to work well.
<div class="form-group form-group-sm">
<label class="col-lg-2 control-label" for="inputLoginSearch">Search for HOA</label>
<div class="col-lg-10">
<div class="input-group" style="max-width: 358px;">
<input id="inputLoginSearch" runat="server" class="form-control" type="text" placeholder="Enter search phrase" style="width: 100%;"/>
<span class="input-group-btn">
<button id="SearchButton" runat="server" class="btn btn-info" type="button">Search</button>
</span>
</div>
</div>
</div>

Bootswatch theme doesnt submit form data

I have the lumen theme from bootswatch... everything seems to be working fine except that my form never submits any data ... it goes to the action page but never send any data across... he is the complete code...
<!DOCTYPE html>
<html>
<title>Some Title
</title>
<link rel="stylesheet" type="text/css" href="bootstrap.css">
<body>
<div class="container">
<div class="row">
<div class="col-lg-12">
<div class="page-header">
<h1 id="container">Some Heading</h1>
</div>
<div class="bs-component">
<div class="jumbotron">
<h1>Incident Management System</h1>
<p> Some heading</p>
<p><a class="btn btn-primary btn-lg">Learn more</a></p>
</div>
</div>
</div>
</div>
</div>
<div class="container">
<div class="row">
<div class="col-lg-8">
<div class="panel panel-success">
<div class="panel-heading">
<h3 class="panel-title">Submit a ticket</h3>
</div>
<div class="panel-body">
<form class="form-horizontal" id="insertForm" method="post" action="addincident.php">
<fieldset>
<legend>We need few details!</legend>
<div class="form-group">
<label for="inputUserName" class="col-lg-2 control-label">Username</label>
<div class="col-lg-10">
<input type="text" class="form-control" id="inputUserName" placeholder="Enter your username">
</div>
</div>
<div class="form-group">
<label for="inputstudentID" class="col-lg-2 control-label">Student ID</label>
<div class="col-lg-10">
<input type="text" class="form-control" id="inputStudentID" placeholder="Enter your Student ID">
</div>
</div>
<div class="form-group">
<label for="inputStudentEmail" class="col-lg-2 control-label">Student EMail</label>
<div class="col-lg-10">
<input type="text" class="form-control" id="inputStudentEMail" placeholder="Enter your Student Email ID">
</div>
</div>
<div class="form-group">
<label for="selectRoomNo" class="col-lg-2 control-label">Room Number</label>
<div class="col-lg-10">
<select class="form-control" id="selectRoomNo">
<option>S114D</option>
<option>S118B</option>
<option>S118E</option>
<option>S120</option>
<option>S114B</option>
</select>
</div>
</div>
<div class="form-group">
<label for="textAreaRoomPosition" class="col-lg-2 control-label">Location of machine</label>
<div class="col-lg-10">
<textarea class="form-control" rows="3" id="textAreaRoomPosition"></textarea>
<span class="help-block">Explain to the best of your knowledge the location of the issue in the lab.</span>
</div>
</div>
<div class="form-group">
<label for="textAreaRoomPosition" class="col-lg-2 control-label">Issue\Incident</label>
<div class="col-lg-10">
<textarea class="form-control" rows="3" id="textAreaRoomPosition"></textarea>
<span class="help-block">Explain to the best of your knowledge the issue you are facing. Try to be as detailed as possible.</span>
</div>
</div>
<div class="form-group">
<div class="col-lg-10 col-lg-offset-2">
<button class="btn btn-default">Cancel</button>
<button type="submit" class="btn btn-primary">Submit</button>
</div>
</div>
</fieldset>
</form>
</div>
</div>
</div>
<div class="col-lg-4">
<div class="panel panel-info">
<div class="panel-heading">
<h3 class="panel-title">Information</h3>
</div>
<div class="panel-body">
Upon recieving the ticket, we will assign it to a designated technician who will then solve the case. You can view the solution of the incident once it is posted.
</div>
</div>
</div>
</div>
</div>
</body>
</html>
It's missing the "name" attribute;
change this:
<input type="text" id="inputUserName">
to something like this:
<input type="text" name="inputUserName" id="inputUserName">

Resources