O'Reilly logo

HTML5 Data and Services Cookbook by Mite Mitreski, Gorgi Kosev

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

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

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required