O'Reilly logo

Bootstrap for Rails by Syed Fazle Rahman

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Validation classes in Bootstrap forms

Bootstrap works well with HTML5's default form validation. Adding an attribute called required to any form element will prevent the form from being submitted. Bootstrap's JavaScript doesn't have any predefined validation functionality. It provides you with CSS classes that can be applied to the form elements on runtime. These classes are important to highlight which form element needs attention by the user.

Let's have a look at some of the form validation classes by Bootstrap:

  • .has-error: This class is used to highlight a red color
  • .has-warning: This class is used to highlight a dull yellow color
  • .has-success: This class is used to highlight a green color

These classes are applied to the .form-group element. For ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required