<!DOCTYPE html>
<html>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.4.8/angular.min.js"></script>
<style>
input.ng-invalid {
background-color: lightblue;
}
</style>
<body>
<form ng-app="" name="myForm" ng-init="myText = 'post@myweb.com'">
Email1:
<input type="email" name="myMail1" ng-model="text" required>
<span ng-show="myForm.myMail1.$error.email">Not a valid e-mail address</span>
<p>Enter your e-mail address in the input field. AngularJS will display an errormessage if the address is not an e-mail.</p>
<br>
Email2:
<input type="email" name="myMail2" ng-model="myText" required>
<p>Edit the e-mail address, and try to change the status.</p>
<h1>Status</h1>
<p>Valid: {{myForm.myMail2.$valid}} (if true, the value meets all criteria).</p>
<p>Dirty: {{myForm.myMail2.$dirty}} (if true, the value has been changed).</p>
<p>Touched: {{myForm.myMail2.$touched}} (if true, the field has been in focus).</p>
</form>
</body>
</html>
Some more classes defined by ng-model directive:
ng-empty
ng-not-empty
ng-touched
ng-untouched
ng-valid
ng-invalid
ng-dirty
ng-pending
ng-pristine
ng-empty
ng-not-empty
ng-touched
ng-untouched
ng-valid
ng-invalid
ng-dirty
ng-pending
ng-pristine
Be the first to comment
You can use [html][/html], [css][/css], [php][/php] and more to embed the code. Urls are automatically hyperlinked. Line breaks and paragraphs are automatically generated.