Validating User Input with Angular Forms
In addition to the properties of a binding we discussed earlier, Angular provides sophisticated features to interact with form data.[82] We can use these features to implement various validations on our input fields using HTML5’s validations. For example, we can indicate a field is required using required like so:
| <input type="text" name="first_name" required> |
HTML5 validations, and thus Angular’s form validations, can do more than just require values. Here are the validations we’re going to implement, and it won’t require very much code to make them work:
- First name, last name, and username are required.
- Email is required and should look like an email address.
- Address and city are required. ...
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.