O'Reilly logo

Rails, Angular, Postgres, and Bootstrap by David B. Copeland

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

Styling Invalid Fields with Bootstrap

Now that we can detect which fields are invalid (and why), we want to show our users this information so they can correct the issue. We could just display a list of errors at the top of the screen, but we can do better. Bootstrap provides classes that allow us to highlight valid and invalid fields as well as show error messages:

images/angular-forms/bootstrap/bootstrap-form-errors.png

Bootstrap refers to this as feedback. To display the error state shown earlier, we’ll add the classes has-feedback and has-error to the div containing our form elements. To make sure the error message text picks up the same red styling, we’ll put it inside a p that uses the help-block ...

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