form-1 validation in Angular
by manoj
HTML
<div ng-app="MyApp">
<h4>Simple form validation</h4>
<div ng-controller="MyCtrl">
<form name="simpleForm">
<table>
<tr>
<td>
<p>
<input type="text" name="text" placeholder="Enter text" ng-model="sf.text" />
</p>
<p>
<input type="email" name="text" placeholder="Enter email" ng-model="sf.email" />
</p>
<p>
<input type="tel" name="text" placeholder="Enter telephone number" ng-model="sf.tel" />
</p>
<p>
<input type="url" name="text" placeholder="Enter a url" ng-model="sf.url" />
</p>
<p>
<input type="number" name="text" placeholder="Enter a number" ng-model="sf.number" />
</p>
</td>
<td>
<table>
<tr>
<td>Is Valid:</td>
<td><b ng-bind="simpleForm.$valid">Valid</b>
</td>
</tr>
<tr>
<td>Is Pristine:</td>
<td><b ng-bind="simpleForm.$pristine">Valid</b>
</td>
</tr>
<tr>
<td>Is Invalid:</td>
<td><b ng-bind="simpleForm.$invalid">Valid</b>
</td>
</tr>
<tr>
<td>Is Dirty:</td>
<td><b ng-bind="simpleForm.$dirty">Valid</b>
...
JavaScript
var myApp = angular.module("MyApp", []);
myApp.controller("MyCtrl", ['$scope', function (s) {
}]);