I'm trying to do password validation in AngularJs.
HTML
<input type="password" id="inputPassword1" name="Password" class="form-control" data-ng-model="passwordd" ng-pattern="/^[A-Za-z0-9_+@&$#!^%*-]{6,10}$/" placeholder="Password" required />
<span ng-show="myForm.Password.$error.pattern"><span style="color:red">Must contain minimum 6 characters</span></span>
<input type="password" id="inputPassword" class="form-control" ng-change="doPwdMatch()" name="password" data-ng-model="password2" placeholder="Confirm Password" required />
<span ng-show="pwdDonotMatch"> <span style="color:red">Passwords don't match.</span> </span>
JS
$scope.doPwdMatch=function(){
if(($scope.password2!=="" || $scope.password2==undefined ) && $scope.passwordd !== $scope.password2){
$scope.pwdDonotMatch = true;
}else
$scope.pwdDonotMatch = false;
}
It showing error if the confirm password does not match with password. But it is not validating if I clear the password field and input some other value. To be specific, reverse checking is not happening.