值我有这样的HTML代码的输入类型数的最小值设定为其他输入类型号
<form method="post" action="cashier.php" enctype="form-data/multipart">
<input required id="amount" type="number" min="0" class="form-control" name="txtamount" placeholder="Enter Payment Here..." />
<input required id="cash" type="number" min="document.getElementById('amount').value" class="form-control" name="txtcash" placeholder="Enter Cash Here..." />
<input type="submit" class="btn btn-primary pull-right" name="btnenroll" value="Done" />
</form>
如果我在ID =“量”键入1000中,ID =“现金”分钟将1000.
但它不起作用。
纯HTML中的'min'属性中不能有动态值。你需要一个JS(也可能是一个库)。 – Pavlo
'min'和'max'属性只能根据类型填充数字或日期。也许你对HTML5约束验证感兴趣http://www.w3.org/TR/2011/WD-html5-20110525/association-of-controls-and-forms.html#constraint-validation –