title: Disable submit when validate confirm password in angularjs
body: <p>I want to disable submit button when validate confirm password. I followed this model: </p>
  
  <p><strong><a href="http://jsfiddle.net/thomporter/UZrex/1/" rel="nofollow">JSFIDDLE</a></strong></p>
  
  <p>Angularjs:</p>
  
  <pre><code> var app = angular.module('myapp', ['UserValidation']);
  
      angular.module('UserValidation', []).directive('validPasswordC', function () {
          return {
              require: 'ngModel',
              link: function (scope, elm, attrs, ctrl) {
                  ctrl.$parsers.unshift(function (viewValue, $scope) {
                      var noMatch = viewValue != scope.myForm.password.$viewValue
                      ctrl.$setValidity('noMatch', !noMatch)
                  })
              }
          }
      }) 
  </code></pre>
  
  <p>view :</p>
  
  <pre><code>&lt;div ng-app="myapp"&gt;
         &lt;form name="myForm"&gt;
  
  
  
             &lt;label for="password"&gt;Password&lt;/label&gt;
             &lt;input type="password" id="password" name="password" ng-model="formData.password" ng-minlength="8" ng-maxlength="20" ng-pattern="/(?=.*[a-z])(?=.*[A-Z])(?=.*[^a-zA-Z])/" required  /&gt;
         &lt;span ng-show="myForm.password.$error.required &amp;&amp; myForm.password.$dirty"&gt;required&lt;/span&gt;
         &lt;span ng-show="!myForm.password.$error.required &amp;&amp; (myForm.password.$error.minlength || myForm.password.$error.maxlength) &amp;&amp; myForm.password.$dirty"&gt;Passwords must be between 8 and 20 characters.&lt;/span&gt;
         &lt;span ng-show="!myForm.password.$error.required &amp;&amp; !myForm.password.$error.minlength &amp;&amp; !myForm.password.$error.maxlength &amp;&amp; myForm.password.$error.pattern &amp;&amp; myForm.password.$dirty"&gt;Must contain one lower &amp;amp; uppercase letter, and one non-alpha character (a number or a symbol.)&lt;/span&gt;
             &lt;br /&gt;
  
  
             &lt;label for="password_c"&gt;Confirm Password&lt;/label&gt;
             &lt;input type="password" id="password_c" name="password_c" ng-model="formData.password_c" valid-password-c required  /&gt;
         &lt;span ng-show="myForm.password_c.$error.required &amp;&amp; myForm.password_c.$dirty"&gt;Please confirm your password.&lt;/span&gt;
         &lt;span ng-show="!myForm.password_c.$error.required &amp;&amp; myForm.password_c.$error.noMatch &amp;&amp; myForm.password.$dirty"&gt;Passwords do not match.&lt;/span&gt;
             &lt;br /&gt;
  
         &lt;button type="submit" class="btn" ng-disabled="!myForm.$valid"&gt;Submit&lt;/button&gt;
          &lt;/form&gt;
         &lt;/div&gt;
  </code></pre>
  
  <p>But the problem is that It does not check for password field, When the submit button enable, I input again password field another values which is different Confirm password and the submit button is still enable.</p>
  
  <p>thankyou verymuch</p>