Using Angular's client-side validation

Angular extends the new HTML5 validation attributes on its own, and allows the users to add error conditions to the template. With these capabilities of Angular, we can add custom error messages and styles to our forms.

In this recipe, we're going to create a simple user registration form in Angular and then we'll add some validation rules to the form.

How to do it...

Let's perform the following steps:

Create a file named index.html that contains the registration form and the validation rules:

<!doctype html> <html ng-app> <head> <script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.0.5/angular.min.js"></script> <style type="text/css"> form { display: block; width: 550px; margin: auto; } input[type="submit"] ...

Get HTML5 Data and Services Cookbook 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.