i am trying to do like this but border color turns red even i type a single letter into the input field and not getting normal till the input is valid. i am wishing to turn the border color red on invalid input but after clicking outside of that textbox. please provide some solution.
<html>
<head>
<style>
input.ng-invalid.ng-dirty{border:1px solid red;}
textarea.ng-invalid.ng-dirty{border:1px solid red;}
/*button{width: 100px;height: 30px;}*/
</style>
</head>
<body>
<div ng-controller="myCtrl" class="form-contact-in">
<form name="frm" ng-submit="submit(frm.$valid)">
<input name="name"
type="text"
ng-model="user.name"
placeholder="Name"
ng-minlength="3"
ng-maxlength="15"
class="contactusform"
required>
<span ng-show="frm.name.$dirty && frm.name.$error.required">Name Required</span>
<span ng-show="frm.name.$dirty && frm.name.$error.minlength">too short</span>
<span ng-show="frm.name.$dirty && frm.name.$error.maxlength">too long</span><br>
<input name="email"
type="email"
ng-model="user.email"
placeholder="Email"
class="contactusform"
required>
<span ng-show="frm.email.$dirty && frm.email.$error.required">Email Required</span>
<span ng-show="frm.email.$dirty && frm.email.$error.email">Enter a valid email</span><br>
<input type="number"
placeholder="Phone Number"
name="mobile"
ng-model="user.mobile"
ng-pattern="mobRegex"
ng-minlength="10"
class="contactusform"
required>
<span ng-show="frm.mobile.$dirty && frm.mobile.$error.required">required</span>
<span ng-show="frm.mobile.$dirty && frm.mobile.$error.number">required</span>
<span ng-show="frm.mobile.$dirty && frm.mobile.$error.pattern">Required a valid mobile no.</span><br>
<textarea name="message"
cols="20"
rows="4"
placeholder="Message"
class="contactusform"
ng-model="user.message"
ng-minlength="5"
required>
</textarea>
<span ng-show="frm.message.$dirty && frm.message.$error.required">required</span>
<span ng-show="frm.message.$dirty && frm.message.$error.minlength">at least 5 chars needed</span><br>
<div class="buttonsec2contactpage">
<button type="submit" class="button-contactform2">SEND</button>
</div>
<p id="contactSubmitMessage">
</p>
</form>
</div>
<script src="https://code.angularjs.org/1.2.3/angular.min.js"></script>
<script>
var app = angular.module("myApp", []);
app.controller("myCtrl", function($scope, $http) {
$scope.mobRegex=/^(?:(?:\+|0{0,2})91(\s*[\-]\s*)?|[0]?)?[789]\d{9}$/;
$scope.submit=function(){
console.log("mobile"+ $scope.user.mobile);
};
});
</script>
</body>
</html>