ここには、パスワードと確認パスワードのような 2 つの入力フィールドがあります。ここで、両方のフィールドでパスワードの一致のような検証を行いたいと考えています。html と js のコード スニペットを次に示します。
var validationApp = angular.module('validationApp',['ngGrid','ui.utils']);
// you have to be put this line of code in your controller
$scope.formData = {
password: "",
cPassword: ""
};
<!-- password -->
<div class="form-group" ng-class="{ 'has-error' : userForm.password.$invalid && !userForm.password.$pristine }">
<label>Password</label>
<input type="password" name="password" class="form-control" ng-model="formData.password" ng-minlength="5" ng-maxlength="12" required>
<p ng-show="userForm.password.$invalid && !userForm.password.$pristine" class="help-block">Required and must be of length 7 to 12.</p>
</div>
<!-- confirm password -->
<div class="form-group" ng-class="{ 'has-error' : userForm.cPassword.$invalid && !userForm.cPassword.$pristine }">
<label>Confirm Password</label>
<input type="password" name="cPassword" class="form-control" ng-model="formData.cPassword" ui-validate=" '$value==formData.password'" ui-validate-watch=" 'formData.password'" ng-minlength="5" ng-maxlength="12" required>
<p ng-show="userForm.cPassword.$invalid && !userForm.cPassword.$pristine" class="help-block">Required. Password not match</p>
</div>