I tried to put green background if it is edited and valid.
But, even for invalid also it is showing green background. On invalid it should show the yellow background with red text.
Thanks in advance for giving me the solution.
html
<div ng-app="myApp" ng-controller="formCtrl">
<form name="inputform">
<div ng-class="{'has-success': inputform.email.$dirty && inputform.email.$valid, 'has-error': inputform.email.$dirty && inputform.email.$invalid}">
<label for="exampleInputEmail1">Email</label>
<input type="text" name="email" ng-model="data.email" id="exampleInputEmail1" />
</div>
</form>
{{data}}
</div>
javascript
var module = angular.module("myApp", []);
module.controller("formCtrl", ['$scope', function($scope){
$scope.data = {};
}]);
css
.has-error {
color: red;
background-color: red;
}
.has-success {
color: black;
background-color: green;
}