Bootstrap Inputs

Bootstrap Input Types

Input type: checkbox

Input type: radio button

Bootstrap Checkbox

Checkbox facilitates you to select any number of options from a list of present options.

See this example:

<!DOCTYPE html>  

<html lang="en">  

<head>  

  <title>Bootstrap Example</title>  

  <meta charset="utf-8">  

  <meta name="viewport" content="width=device-width, initial-scale=1">  

  <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css">  

   

</head>  

<body>  

  

<div class="container">  

  <h2>Input type: checkbox</h2>  

  <form role="form">  

    <div class="checkbox">  

      <label><input type="checkbox" value="">Option 1</label>  

    </div>  

    <div class="checkbox">  

      <label><input type="checkbox" value="">Option 2</label>  

    

    </div>  

  </form>  

</div>  

 <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.0/jquery.min.js"></script>  

 <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/js/bootstrap.min.js"></script>  

</body>  

</html> 

Use the .checkbox-inline class if you want the checkboxes to appear on the same line:

See this example:

<!DOCTYPE html>  

<html lang="en">  

<head>  

  <title>Bootstrap Example</title>  

  <meta charset="utf-8">  

  <meta name="viewport" content="width=device-width, initial-scale=1">  

  <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css">  

    

</head>  

<body>  

  

<div class="container">  

  <h2>Inline checkbox</h2>  

  <p>The following checkboxes appear in the same line :</p>  

  <form role="form">  

    <label class="checkbox-inline">  

      <input type="checkbox" value="">Option 1  

    </label>  

    <label class="checkbox-inline">  

      <input type="checkbox" value="">Option 2  

    </label>  

  </form>  

</div>  

<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.0/jquery.min.js"></script>  

<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/js/bootstrap.min.js"></script>  

</body>  

</html> 

Bootstrap Radio Buttons

Radio buttons also facilitates you to select any number of options from a list of present options.

See this example:

<!DOCTYPE html>  

<html lang="en">  

<head>  

  <title>Bootstrap Example</title>  

  <meta charset="utf-8">  

  <meta name="viewport" content="width=device-width, initial-scale=1">  

  <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css">  

    

</head>  

<body>  

<div class="container">  

  <h2>Input type: Radio buttons</h2>  

    

  <form role="form">  

    <div class="radio">  

      <label><input type="radio" name="optradio">Option 1</label>  

    </div>  

    <div class="radio">  

      <label><input type="radio" name="optradio">Option 2</label>  

    </div>  

  </form>  

</div>  

<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.0/jquery.min.js"></script>  

<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/js/bootstrap.min.js"></script>  

</body>  

</html> 

Use the .radio-inline class if you want the radio buttons to appear on the same line:

See this example:

<!DOCTYPE html>  

<html lang="en">  

<head>  

  <title>Bootstrap Example</title>  

  <meta charset="utf-8">  

  <meta name="viewport" content="width=device-width, initial-scale=1">  

  <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css">  

    

</head>  

<body>  

  

<div class="container">  

  <h2>Inline radio buttons</h2>  

  <p>The following radio boxes appear in the same line:</p>  

  <form role="form">  

    <label class="radio-inline">  

      <input type="radio" name="optradio">Option 1  

    </label>  

    <label class="radio-inline">  

      <input type="radio" name="optradio">Option 2  

    </label>  

  </form>  

</div>  

<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.0/jquery.min.js"></script>  

<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/js/bootstrap.min.js"></script>  

</body>  

</html>

Bootstrap 4 Inputs

Bootstrap 4 supports following types of form controls:

  • input
  • textarea
  • checkbox
  • radio
  • select

Bootstrap Input

Bootstrap supports all the HTML5 input types: text, password, datetime, datetime-local, date, month, time, week, number, email, url, search, tel, and color.

Note: Inputs will NOT be fully styled if their type is not properly declared!

Example:

<!DOCTYPE html>  

<html lang="en">  

<head>  

  <title>Bootstrap Example</title>  

  <meta charset="utf-8">  

  <meta name="viewport" content="width=device-width, initial-scale=1">  

  <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-beta.2/css/bootstrap.min.css">  

  <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>  

  <script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.12.6/umd/popper.min.js"></script>  

  <script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-beta.2/js/bootstrap.min.js"></script>  

</head>  

<body>  

<div class="container">  

  <h2>Form control: input example</h2>  

  <form>  

    <div class="form-group">  

      <label for="usr">Name:</label>  

      <input type="text" class="form-control" id="usr">  

    </div>  

    <div class="form-group">  

      <label for="pwd">Password:</label>  

      <input type="password" class="form-control" id="pwd">  

    </div>  

  </form>  

</div>  

</body>  

</html>  

Bootstrap Textarea

Use textarea with “form-control” to create a Bootstrap textarea.

Example:

<!DOCTYPE html>  

<html lang="en">  

<head>  

  <title>Bootstrap Example</title>  

  <meta charset="utf-8">  

  <meta name="viewport" content="width=device-width, initial-scale=1">  

  <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-beta.2/css/bootstrap.min.css">  

  <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>  

  <script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.12.6/umd/popper.min.js"></script>  

  <script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-beta.2/js/bootstrap.min.js"></script>  

</head>  

<body>  

<div class="container">  

  <h2>Form control: textarea</h2>  

  <p>The form below contains a textarea for comments:</p>  

  <form>  

    <div class="form-group">  

      <label for="comment">Comment:</label>  

      <textarea class="form-control" rows="5" id="comment"></textarea>  

    </div>  

  </form>  

</div>  

</body>  

</html> 

Bootstrap Select List

Bootstrap Select List is used to select single or multiple list. Select list is used if you want to allow the user to pick form multiple options.

Example:

<!DOCTYPE html>  

<html lang="en">  

<head>  

  <title>Bootstrap Example</title>  

  <meta charset="utf-8">  

  <meta name="viewport" content="width=device-width, initial-scale=1">  

  <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-beta.2/css/bootstrap.min.css">  

  <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>  

  <script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.12.6/umd/popper.min.js"></script>  

  <script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-beta.2/js/bootstrap.min.js"></script>  

</head>  

<body>  

<div class="container">  

  <h2>Form control: select</h2>  

  <p>The form below contains two dropdown menus (select lists):</p>  

  <form>  

    <div class="form-group">  

      <label for="sel1">Select list (select one):</label>  

      <select class="form-control" id="sel1">  

        <option>1</option>  

        <option>2</option>  

        <option>3</option>  

        <option>4</option>  

      </select>  

      <br>  

      <label for="sel2">Mutiple select list (hold shift to select more than one):</label>  

      <select multiple class="form-control" id="sel2">  

        <option>1</option>  

        <option>2</option>  

        <option>3</option>  

        <option>4</option>  

        <option>5</option>  

      </select>  

    </div>  

  </form>  

</div>  

</body>  

</html>

Comments

Leave a Reply

Your email address will not be published. Required fields are marked *