Lecture 4
Lecture 4
- Inline form
- Horizontal form
<div class="container">
<div class="row">
<div class="col-md-4 col-md-offset-4">
</form>
</div>
<div class="panel-footer"> Using Bootstrap Vertical Form (default) </div>
</div>
</div>
</div>
</div>
Tip: If you don't include a label for every input, screen readers will have trouble with your forms. You
can hide the labels for all devices, except screen readers, by using the sr-only class:
Bootstrap Inline Form
- In an inline form, all of the elements are inline, left-aligned, and the labels are alongside.
- Note: This only applies to forms within viewports that are at least 768px wide!
<div class="container">
<div class="row">
<div class="col-md-12">
</form>
</div>
<div class="panel-footer"> Using Bootstrap Inline Form</div>
</div>
</div>
</div>
</div>
Bootstrap Horizontal Form
- A horizontal form stands apart from the other forms both in the amount of markup, and in
the presentation of the form.
- Add class form-horizontal to the <form> element
- Add class control-label to all <label> elements
- Use Bootstrap's predefined grid classes to align labels and groups of form controls in a horizontal layout.
<div class="container">
<div class="row">
<div class="col-md-8">
</div>
<div class="panel-footer"> Using Bootstrap Horironzal Form</div>
</div>
</div>
</div>
</div>
Bootstrap Form Control States
DISABLED INPUTS
- Add a disabled attribute to disable an input field
Example
<div class="form-group">
<label for="Name"> Disable Text</label>
<input type = "text" class="form-control" name = "txtname" placeholder="Disabled Text" required disabled />
</div>
<div class="form-group">
<label for="Department">Disabled Select</label>
<select class="form-control" name="txtdepartment" disabled>
<option>ICT</option>
<option>Automotive</option>
<option>Construction</option>
<option>Manufacturing</option>
<option>Electrical-Electronics</option>
<option>Garments</option>
<option>Railways</option>
</select>
</div>
<div class="form-group">
<button type="submit" name="submit" class="btn btn-block btn-social btn-primary" disabled><i class="fa fa-bitbucket"></i>
Disabled Button</button>
</div>
READONLY INPUTS
- Add a readonly attribute to an input to prevent user input
Example
<div class="form-group">
<label for="Name"> ReadOnly Text</label>
<input type = "text" class="form-control" name = "txtname" placeholder="Readonly Text" required readonly />
</div>
VALIDATION STATES
- Bootstrap includes validation styles for error, warning, and success messages.
- To use, add has-warning, has-error, or has-success to the parent
element Example:
ICONS
- You can add feedback icons with the has-feedback class and an icon
INPUT GROUPS
- Include the input-group under your <div class="form-group">
- Use <span class="input-group-addon"> for the icon or text.
HIDDEN LABELS
- Add a sr-only class on non-visible labels
Try the following:
1. Formlayout.php
2. Formlayout2.php
3. Employee.php