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 ...

Get Rails, Angular, Postgres, and Bootstrap now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.