Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Angular form error if two fields dont match

Is there a way to make a form invalid if two inputs don't match (like passwords), in Angular? Similar to form.password.$error.required?

like image 484
user718229 Avatar asked Feb 13 '23 16:02

user718229


1 Answers

 pwd1:<input type="password" ng-model="pwd1" required /><br />
 pwd2:<input type="password" ng-model="pwd" required /><br />

      <div ng-show="pwd1 && pwd">Invalid:
        <span ng-show="pwd1!==pwd">Wrong</span>
        <span ng-show="pwd1===pwd">Correct</span>
      </div>

This just checks if both the passwords are same. Angular Form validation

Also check this Angular Ui which has password match directive

like image 184
Srinath Avatar answered Feb 15 '23 11:02

Srinath