Earlier I demonstrated the angular form validation example: Angularjs's Form validation example, in fact, we can use angular provided module messages for easier form validation,
<html>
<head>
<link href="//cdn.bootcss.com/bootstrap/3.3.5/css/bootstrap.min.css" rel="stylesheet">
<script src="//cdn.bootcss.com/angular.js/1.4.4/angular.js"></script>
<script src="angular-messages.js" type="text/javascript" charset="utf-8"></script>
<script type="text/javascript">
var app = angular.module('app', ['ngMessages']);
app.controller('Ctrl',function () {
}
</script>
</head>
<style type="text/css">
.error{color: indianred;}
.success{color: green;}
</style>
<body ng-app='app'>
<div ng-controller="Ctrl">
<form class="form-horizontal" name="form" role="form">
<div class="form-group">
< label for = "user" class = "col-sm-2 control label" > user name < / label >
<div class="col-sm-5">
<input type="text" ng-model="user.username" name="user" ng-pattern="/^[a-zA-Z]\w{2,10}[a-zA-Z\d]$/" class="form-control" required="required">
</div>
<div ng-messages="form.user.$error">
< div ng message = "required" > required items < / div >
< div ng message = "pattern" > non conformance < / div >
</div>
</div>
< button ng disabled = "form. $invalid" > submit < / button >
</form>
</div>
</body>
</html>