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"] { margin-left: 215px; } span.err { color: #f00; } label { width: 120px; display:inline-block; text-align: right; } </style> </head> <body> <div> <form name="register...