0

我正在尝试在 2 个数字输入之间进行范围验证。输入代表base remunerationtop remuneration。我尝试像这样使用ui-validate-watch :http: //jsfiddle.net/GNJP4/3/。问题是基本上lowerBound没有正确更新(与 相同upperBound

如果您有解决方法或使用指令的想法(我尝试过但一团糟),将不胜感激。

4

1 回答 1

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>

于 2015-06-12T04:35:00.597 回答