i created a controller and form with validation rules, but i'm struggling to ensure that the confirm_password
matches the password
?
html
<div class="col-md-5" ng-controller="RegisterController as vm">
<form id="sign_up" name="SignUp" ng-submit="vm.register(SignUp)" novalidate>
<div class="box_form">
<div class="form-group">
<label>Email</label>
<input type="email" class="form-control" name="email" ng-model="vm.email" placeholder="Your email" required>
<p ng-show="(SignUp.email.$error.email || SignUp.email.$error.required) && (SignUp.terms.$dirty || vm.submitted)" class="help-block ng-binding"
style="">Email is invalid.</p>
</div>
<div class="form-group">
<label>Username</label>
<input type="text" class="form-control" name="username" ng-model="vm.username" ng-minlength="3" ng-maxlength="14" placeholder="Your username"
required>
<p ng-show="SignUp.username.$error. && (SignUp.username.$dirty || vm.submitted)" class="help-block ng-binding" style="">Username is invalid.</p>
</div>
<div class="form-group">
<label>Password</label>
<input type="password" class="form-control" name="password" ng-model="vm.password" ng-minlength="6" ng-maxlength="24" placeholder="Your password"
required>
<p ng-show="SignUp.password.$error && (SignUp.password.$dirty || vm.submitted)" class="help-block ng-binding" style="">Password is invalid.</p>
</div>
<div class="form-group">
<label>Confirm Password</label>
<input type="password" class="form-control" name="confirm_password" ng-model="vm.confirm_password" ng-minlength="6" ng-maxlength="24"
ng-model="vm.confirm_password" placeholder="Confirm your password" required>
<p ng-show="(SignUp.confirm_password.$dirty || vm.submitted)" class="help-block ng-binding">Passwords do not match.</p>
</div>
<div class="checkbox-holder text-left">
<div class="checkbox_2">
<input type="checkbox" value="accept" id="check_2" name="terms" ng-model="terms" required>
<label for="check_2">
<span>I Agree to the
<strong>Terms & Conditions</strong>
</span>
</label>
</div>
</div>
<!-- validation -->
<p class="alert alert-danger text-center" ng-show="SignUp.terms.$error.required && (SignUp.terms.$dirty || vm.submitted)">Please accept terms and conditions.</p>
<div class="form-group text-center add_top_30">
<button class="btn_1" id="sign_up_btn" type="submit">Sign Up</button>
</div>
</div>
</form>
</div>
controller
(function () {
'use strict';
angular
.module('KryptoApp')
.controller('RegisterController', RegisterController);
RegisterController.$inject = ['$location', '$scope', 'Authentication'];
function RegisterController($location, $scope, Authentication) {
var vm = this;
vm.register = register;
function register(form) {
vm.submitted = true;
if(form.$valid) {
Authentication.register(vm.email, vm.password, vm.confirm_password, vm.username);
}
}
}
})();