Bootstrap Tutorial - Mark Forms Validation States








The following code shows how to mark Forms Validation States.

Example

<!DOCTYPE html>
<html lang="en">
<head>
<link rel="stylesheet"
  href="http://netdna.bootstrapcdn.com/bootstrap/3.0.3/css/bootstrap.min.css">
<link rel="stylesheet"
  href="http://netdna.bootstrapcdn.com/bootstrap/3.0.3/css/bootstrap-theme.min.css">
<script type="text/javascript"
  src="http://code.jquery.com/jquery.min.js"></script>
<script
  src="http://netdna.bootstrapcdn.com/bootstrap/3.0.3/js/bootstrap.min.js"></script>
<style type="text/css">
.bs-example {<!--   ww  w . j  a  va2  s. c om-->
  margin: 20px;
}
</style>
</head>
<body>
  <div class="bs-example">
    <form class="form-horizontal">
      <div class="form-group has-success">
        <label class="col-xs-2 control-label" for="inputSuccess">Username</label>
        <div class="col-xs-10">
          <input type="text" id="inputSuccess" class="form-control"
            placeholder="Input with success"> <span class="help-block">Username
            is available</span>
        </div>
      </div>
      <div class="form-group has-warning">
        <label class="col-xs-2 control-label" for="inputWarning">Password</label>
        <div class="col-xs-10">
          <input type="password" id="inputWarning" class="form-control"
            placeholder="Input with warning"> <span class="help-block">Password
            strength: Weak</span>
        </div>
      </div>
      <div class="form-group has-error">
        <label class="col-xs-2 control-label" for="inputError">Email</label>
        <div class="col-xs-10">
          <input type="email" id="inputError" class="form-control"
            placeholder="Input with error"> <span class="help-block">Please
            enter a valid email address</span>
        </div>
      </div>
    </form>
  </div>
</body>
</html>

Click to view the demo