title: Validate a group of form fields with AngularJS
body: <p>Working with Angular 1.5.11</p>
  <p>I have a html form with several fileds like :</p>
  <pre><code>&lt;div ng-app=&quot;validationApp&quot; ng-controller=&quot;mainController&quot;&gt;
    &lt;div class=&quot;container&quot;&gt;
      &lt;div class=&quot;row&quot;&gt;
        &lt;form name=&quot;weightForm&quot; ng-submit=&quot;submitForm()&quot; novalidate&gt;
          &lt;input class=&quot;input&quot; data-required=&quot;&quot; fn-restrict-integer=&quot;&quot; maxlength=&quot;4&quot; name=&quot;weight1&quot; id=&quot;weight1&quot; ng-model=&quot;weight1&quot; fn-min-value=&quot;1&quot; fn-max-value=&quot;9999&quot; /&gt;
          &lt;input class=&quot;input&quot; data-required=&quot;&quot; fn-restrict-integer=&quot;&quot; maxlength=&quot;4&quot; name=&quot;weight2&quot; id=&quot;weight2&quot; ng-model=&quot;weight2&quot; fn-min-value=&quot;1&quot; fn-max-value=&quot;9999&quot; /&gt;
          &lt;input class=&quot;input&quot; data-required=&quot;&quot; fn-restrict-integer=&quot;&quot; maxlength=&quot;4&quot; name=&quot;weight3&quot; id=&quot;weight3&quot; ng-model=&quot;weight3&quot; fn-min-value=&quot;1&quot; fn-max-value=&quot;9999&quot; /&gt;
  
          &lt;div&gt;
            &lt;dl aria-invalid=&quot;{{totalWeightIsAboveLimit()}}&quot;&gt;
              &lt;p class=&quot;input__error&quot;&gt;total weight above limit&lt;/p&gt;
            &lt;/dl&gt;          
          &lt;/div&gt;
  
          &lt;button type=&quot;submit&quot; class=&quot;btn btn-primary&quot; ng-disabled=&quot;weightForm.$invalid&quot;&gt;Submit&lt;/button&gt;
        &lt;/form&gt;
      &lt;/div&gt;
    &lt;/div&gt;
  &lt;/div&gt;
  </code></pre>
  <p>How can I build a validation that considers the values of the three fields as a group, in this case the sum of the fields entered.</p>
  <p>I have built a validation function function to toggle the message, but I don't know how to make the form invalid, based on the outcome of this function.</p>
  <p>But I don't know how to make the whole form inavalid to prevent the submit.</p>