Matt Whetton
Matt Whetton

Reputation: 6786

Bootstrap 3 validation states with input groups

How do add bootstrap 3 validation states to input groups. The state seems to only apply to the input part of the group.

EDIT 10/02/2014: To clarify, I'm using an input group with a button:

<div class="form-group has-success col-md-3">
  <label class="control-label"></label>
  <div class="input-group">
    <input type="text" class="form-control">
    <span class="input-group-btn">
      <button class="btn btn-default" type="button">Go!</button>
    </span>
  </div>
</div>

http://bootply.com/112305

Upvotes: 3

Views: 12367

Answers (2)

ragamufin
ragamufin

Reputation: 4162

The trick is to place the actual input in its own block. Try the following:

<div class="form-group has-feedback">
    <div class="input-group">
        <div style="position:relative"><!-- sub container for the input and validation state -->
            <input name="emailAddress" type="text" class="form-control" value="">
            <span class="glyphicon glyphicon-remove form-control-feedback"><!----></span>
        </div>
        <span class="input-group-btn">
            <button id="button-send" type="submit" class="btn btn-primary">Go!</button>
        </span>
    </div>
</div>

Upvotes: 5

Carol Skelly
Carol Skelly

Reputation: 362880

Wrap it inside a form-group and apply the validation state class to the form-group..

<div class="form-group has-success col-md-3">
  <label class="control-label"></label>
  <div class="input-group">
    <input type="text" class="form-control">
    <span class="input-group-addon">00</span>
  </div>
</div>

http://bootply.com/111979

Upvotes: 0

Related Questions