Подскажите как свалидировать поле пароль на сравнение с первым тоесть я проверяю первое поле пароля с вторым и если они равны то кнопку разблокирую
JS
.directive('pwCheck', function () {
return {
require: 'ngModel',
link: function (scope, elem, attrs, ctrl) {
var me = attrs.ngModel;
var matchTo = attrs.pwCheck;
scope.$watch('[me, matchTo]', function(value){
ctrl.$setValidity('pwmatch', scope[me] === scope[matchTo] );
});
}
}
})
<form novalidate name="regForm" ng-submit="submit()">
<div class="row">
<label for="name">Имя: </label><input name="name" ng-model="dataRegForm.name" type="text" ng-required="">
</div>
<div class="row">
<label for="name">Email: </label><input name="email" ng-model="dataRegForm.email" type="email" ng-required="">
</div>
<div class="row">
<label for="pass">Ваш пароль: </label><input name="pass" ng-model="dataRegForm.password" type="password" ng-required="">
</div>
<div class="row">
<label for="pass">Повторите пароль: </label><input name="pass2" ng-model="dataRegForm.password_two" type="password" pw-check="dataRegForm.password" ng-required="">
</div>
<div class="msg-block" ng-show="true"> <span class="msg-error" ng-show="regForm.dataRegForm.password_two.$error.pwmatch">Passwords don't match.</span>
</div>
<div class="row">
<input ng-disabled="regForm.$invalid" type="submit" value="Войти">
</div>
</form>