Plunker
<ul ng-repeat="fields in data">
<li>
<input type="text" ng-model="fields.field2.i">
</li>
<li>
<input type="text" ng-model="fields.field2.ii">
</li>
<li>
<input type="text" ng-model="fields.field2.iii">
</li>
</ul>
How to check all the fields is filled or not in angularjs? Check the ng-model or the json's object?
Plunker
<ul ng-repeat="fields in data">
<li>
<input type="text" ng-model="fields.field2.i">
</li>
<li>
<input type="text" ng-model="fields.field2.ii">
</li>
<li>
<input type="text" ng-model="fields.field2.iii">
</li>
</ul>
How to check all the fields is filled or not in angularjs? Check the ng-model or the json's object?
Share Improve this question edited Sep 25, 2018 at 6:06 Prashant Pokhriyal 3,8374 gold badges31 silver badges41 bronze badges asked Mar 17, 2015 at 13:43 Dean JasonDean Jason 1051 gold badge1 silver badge9 bronze badges 01 Answer
Reset to default 2Check this plunker
<!DOCTYPE html>
<html ng-app="plunker">
<head>
<meta charset="utf-8" />
<title>AngularJS Plunker</title>
<script>document.write('<base href="' + document.location + '" />');</script>
<link rel="stylesheet" href="style.css" />
<script data-require="[email protected]" src="https://code.angularjs/1.2.28/angular.js" data-semver="1.2.28"></script>
<script src="app.js"></script>
</head>
<body ng-controller="MainCtrl">
<form name="form">
<ul ng-repeat="fields in data">
<li>
<input type="text" ng-model="fields.field2.i" required>
</li>
<li>
<input type="text" ng-model="fields.field2.ii" required>
</li>
<li>
<input type="text" ng-model="fields.field2.iii" required>
</li>
</ul>
<button type="button" ng-disabled="form.$invalid" ng-click="save()">Save</button>
</form>
</body>
</html>
Basically, you should use 'required' on all the required fields and only allow the click on the save button if all fields are fulfilled. This is the very basic form of validation, for more information see this link