laravel - 根据 Laravel 中的另一个字段设置字段的最小值
问题描述
我的表单中有一个start
和stop
字段,我希望用户输入一个start
字段然后输入该stop
字段,但是,该字段的最小值stop
需要是该start
字段的值。有什么办法可以做到这一点?
我的观点:
<div class="mb-3" style="float:left;" style="margin-left: 200px;">
<label for="recipient-name" style="width: 7em"class="col-form-label">Start</label>
<input type="number"style="width: 7em" name="start" class="form-control" id="start" min="0" required>
<div class="mb-3" style="float:left;" style="margin-left: 200px;">
<label for="recipient-name" style="width: 7em"class="col-form-label">Stop</label>
<input type="number"style="width: 7em" name="stop" class="form-control" id="stop" min="0" required>
</div>
解决方案
使用这个简单的 jQuery 方法:
Add `disabled` attribute in your stop input Html
<input type="number"style="width: 7em" name="stop" class="form-control"
disabled id="stop" min="0" required>
然后使用jQuery:
$(document).on('blur','#start',function(){
//make stop input disabled false after focus out from start input
$("#stop").prop("disabled",false);
//set stop input minimum value to start value
$("#stop").attr("min",$("#start").val());
$("#stop").val($("#start").val());
});
推荐阅读
- arrays - VBA:使用数组作为字典对象中的键?
- javascript - 以 EJS 形式在空格后丢失数据
- javascript - d3 强制链接上的网络图文本在 Firefox 中显示,但在 google chrome 中不显示。知道为什么吗?
- git - 错误:RPC 失败;HTTP 502 curl 22 The requested URL returned error: 502 Bad Gateway fatal
- javascript - 当 div 打开时,SlideToggle 动画被跳过或没有发生
- django - 在我已经编辑完views.py之后,Django一直报告同样的错误
- nginx - nginx *104 "/var/www/html/" 的目录索引被禁止
- javascript - 如何在 Node 中自动将 xlsx 转换为 pdf?
- c++ - 处理 std::variant 中的循环依赖
- swift - 当@State变量以高频率刷新视图时,导航栏-/工具栏按钮不可靠