具有最小/最大参数的验证编号
Validation number with min/max parameters
有两个字段。我需要一个比第二个小,第二个比第一个多,同时通过验证。
然而,当输入第一个数字时,不会保存在模型中(保存为未定义),因为没有通过验证条件"最大"
对我来说重要的是键盘输入而不是按钮
有人能帮我解决这个问题吗?
<td><input type="number" class="form-control input-sm" ng-model="item.low" max="{{item.high-1}}" required></td>
<td><input type="number" class="form-control input-sm" ng-model="item.high" min="{{item.low+1}}" required></td>
您是否尝试在控制器中初始化item.low和item.high的值?
<!DOCTYPE html>
<html data-ng-app>
<head>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.25/angular.min.js"></script>
<link rel="stylesheet" href="style.css" />
<script src="script.js"></script>
</head>
<body ng-init="item.low=0;item.high=1;">
<input type="number" class="form-control input-sm" ng-model="item.low" max="{{item.high-1}}" required>
<input type="number" class="form-control input-sm" ng-model="item.high" min="{{item.low+1}}" required>
<p>item.high={{item.high}}</p>
<p>item.low={{item.low}}</p>
</body>
</html>
这比我想象的更容易
我刚刚删除了第一个INPUT中对max的测试,他没有必要并且验证成功并且数据是正确的
<td><input type="number" class="form-control input-sm" ng-model="item.low" required></td>
<td><input type="number" class="form-control input-sm" ng-model="item.high" min="{{item.low+1}}" required></td>
ty all for help
相关文章:
- JavaScript参数验证
- sinon.js验证mock方法's带回调的参数
- 日期验证参数
- Duo-security:如何在双因素身份验证中通过Duo.init()上的post_argument传递参数
- Stripe Connect Charge-必须作为连接帐户进行身份验证才能使用客户参数
- 表单's自定义“;“多参数”;验证器并不总是启动
- AngularJS:转发到登录页面进行身份验证,保留路由作为GET参数
- 验证请求参数的最佳方法是帆.js/节点.js
- 节点.js - 快速.js URL 参数验证
- Javascript 电话号码验证 参数符号
- 使用hapijs/joi验证参数之间的关系
- 在 SailsJS 中验证请求参数
- 验证后恢复参数
- 如何在用户验证后打开新窗口并提取参数
- Hapijs和Joi:验证存在的查询参数:'禁止'
- 具有最小/最大参数的验证编号
- Hapijs在身份验证前验证参数
- 这是验证函数接收的参数的最佳方式
- 主干:验证仅在set()参数上运行
- 如何获得验证码客户端验证参数g-recaptcha-响应后,用户确认他不是一个机器人