Bootstrap Tutorial - Mark form input field as has-error








The following code shows how to mark form input field as has-error.

Example

<!DOCTYPE html>
<html>
<head>
<script type='text/javascript'
  src='http://code.jquery.com/jquery-git2.js'></script>
<link rel="stylesheet" type="text/css"
  href="http://getbootstrap.com/assets/css/docs.css">
<link rel="stylesheet" type="text/css"
  href="http://netdna.bootstrapcdn.com/bootstrap/3.0.0-rc1/css/bootstrap.min.css">
<script type='text/javascript'
  src="http://netdna.bootstrapcdn.com/bootstrap/3.0.0-rc1/js/bootstrap.min.js"></script>
</head><!--from  ww  w.j a v  a2  s.c o m-->
<body style='margin:30px'>
  <form class="form-horizontal">
    <div class="form-group has-error">
      <label for="inputName" class="col-lg-2 control-label">Name</label>
      <div class="col-lg-10">
        <input type="text" class="form-control" id="inputName"
          placeholder="what's your name boy?">
      </div>
    </div>
  </form>

</body>
</html>

Click to view the demo