Marrying Angular’s and Bootstrap’s Form Validations

Bootstrap provides classes that, when applied to form elements, can indicate to the user that the data in that element is correct or incorrect. Angular provides features to describe the valid state of data in a form element as well as a way to check a field’s validity with code. We just need to connect Bootstrap’s styles with Angular’s form validations.

For our form, we’ll keep things simple. We’ll require that every field has a value, and we’ll additionally require that zip code fields look like zip codes. We may need more sophisticated validations in the future, but this will be enough to learn how they work.

Don’t make these changes to all the text fields just yet. We’re going to make ...

Get Rails, Angular, Postgres, and Bootstrap, 2nd Edition 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.