title: Password validation using angular
body: <ul>
  <li>I want to Keep $ symbol in the password.But it is a Showing error message if the password and confirm password same also.</li>
  </ul>
  
  <hr>
  
  <pre><code>&lt;!DOCTYPE html&gt;
  &lt;html&gt;
  &lt;script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.6.4/angular.min.js"&gt;&lt;/script&gt;
  
  &lt;body&gt;
  
  &lt;div ng-app=""&gt;
      &lt;form id="registerform" class="form-horizontal" role="form" novalidate="novalidate" name="registrationForm"&gt;
          &lt;div style="margin-bottom: 25px" ng-class="{ 'has-error' : registrationForm.password.$invalid &amp;&amp; !registrationForm.password.$pristine }"&gt;
  
              &lt;input id="register-password1" type="password" class="form-control" name="password" placeholder="Password" ng-model="password" ng-maxlength="25" ng-minlength="6" ng-required="true" onkeypress="return (event.which != 32)"&gt;
  
              &lt;p ng-show="registrationForm.password.$error.required &amp;&amp; !registrationForm.password.$pristine" class="help-block errosClass"&gt;Please enter password&lt;/p&gt;
              &lt;p ng-show="registrationForm.password.$dirty &amp;&amp; registrationForm.password.$error.maxlength" class="help-block errosClass"&gt;Password cannot be more than 25 characters&lt;/p&gt;
              &lt;p ng-show="registrationForm.password.$dirty &amp;&amp; registrationForm.password.$error.minlength" class="help-block errosClass"&gt;Password cannot be less than 6 characters&lt;/p&gt;
          &lt;/div&gt;
          &lt;div style="margin-bottom: 10px" ng-class="{ 'has-error' : registrationForm.cpassword.$invalid &amp;&amp; !registrationForm.cpassword.$pristine }"&gt;
  
              &lt;input id="register-confirm-password" type="password" class="form-control" name="cpassword" placeholder="Confirm Password" ng-model="cpassword" ng-pattern="password" required="required" onkeypress="return (event.which != 32)"&gt;
  
              &lt;p ng-show="registrationForm.cpassword.$error.required &amp;&amp; !registrationForm.cpassword.$pristine" class="help-block errosClass"&gt;Please enter confirm password&lt;/p&gt;
              &lt;p ng-show="registrationForm.cpassword.$error.pattern" class="help-block errosClass"&gt;Your password and confirm password not match.&lt;/p&gt;
          &lt;/div&gt;
      &lt;/form&gt;
  
  &lt;/div&gt;
  
  &lt;/body&gt;
  
  &lt;/html&gt;
  </code></pre>
  
  <p><a href="https://jsfiddle.net/bjm9ze44/3/" rel="nofollow noreferrer">Code Here</a></p>