如何为两个数字的范围设置验证。我想将第一个数字的最大值设置为第二个数字的值,将第二个数字的最小值设置为第一个麻木的值。这是我的js代码:
min_num : {
validators : {
integer : {
message : 'Please enter the valid number ',
min : 1,
max : 'max_num'
},
notEmpty : {
message : 'Please enter the number'
}
}
},
max_num : {
validators : {
integer : {
message : 'Please enter the valid number ',
min : 'min_num',
max : 10000
},
notEmpty : {
message : 'Please enter the number'
}
}
}
和HTML:
<div class="form-group">
<label class="col-md-2 control-label">Min num</label>
<div class="col-md-4 inputGroupContainer">
<div class="input-group">
<span class="input-group-addon"> </span> <input type="number"
class="form-control" id="min_num" name="min_num" min="0"
required data-bind="value:replyNumber" />
</div>
</div>
</div>
<div class="form-group">
<label class="col-md-2 control-label">Max num</label>
<div class="col-md-4 inputGroupContainer">
<div class="input-group">
<span class="input-group-addon"> </span> <input type="number"
class="form-control" id="max_num" name="max_num" min="0" required
data-bind="value:replyNumber" />
</div>
</div>
</div>
请帮助
答案 0 :(得分:0)
我找到了解决方案。只是改变了我的HTML代码,它完美无缺:D
<div class="form-group">
<label class="col-md-2 control-label">Min num</label>
<div class="col-md-4 inputGroupContainer">
<div class="input-group">
<span class="input-group-addon"> </span> <input type="number"
class="form-control" id="min_num" name="min_num" min="0"
required data-bind="value:replyNumber" />
</div>
</div>
</div>
<div class="form-group">
<label class="col-md-2 control-label">Max num</label>
<div class="col-md-4 inputGroupContainer">
<div class="input-group">
<span class="input-group-addon"> </span> <input type="number"
class="form-control" id="max_num" name="max_num"
min=min_num required
data-bind="value:replyNumber" />
</div>
</div>
</div>