0

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?

0

1 Answer 1

2

Check 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.org/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

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.