forms – OnlineWebTutorial.Com

Using Forms – AngularJS

AngularJS provides following flags to handle errors and validating the input. $dirty − indicates that value has is changed. $invalid − indicates that value is invalid. $error − gives the specific error. <script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.6.1/angular.min.js"></script> <div ng-app="clickApp" ng-controller="clickCtrl"> <form name = "testFrm" novalidate> Enter name: <input type = "text" name = "tname" ng-model = "tname" required /> <span style = "color:red" ng-show = "testFrm.tname.$dirty && testFrm.tname.$invalid"> <span ng-show = "testFrm.tname.$error.required">Name is empty.</span> </span><br /> <input type = "email" name = "email" ng-model = "email" length = "20" required /> <span style = "color:red" ng-show = "testFrm.email.$dirty && testFrm.email.$invalid"> <span ng-show = […]


Facebook
Google+
Twitter
Visit Us
PINTEREST
LinkedIn