我需要限制名称中的最大输入值=" name"领域。
实时处理。 <input max = 100>
约束不起作用。
我怎么能这样做?
<script>
function showcost() {
document.getElementById("cost").value = document.getElementById('serviceslist').value;
}
function sum2() {
var x = document.getElementById('cost2').value;
var y = document.getElementById('amount2').value;
var total = (parseFloat(x) * parseFloat(y))/100;
document.getElementById("total2").value = total;
}
</script>
<br>
<div class="container">
<div class="row">
<div class="col-md-12 col-md-offset-0">
<form>
<p>Procent:<input name="name" size="3" min=1 max=100 type="number" id="amount2" step=1 id="cost2" pattern="[0-9]" onchange="sum2()" oninput="this.value = this.value.replace(/[^0-9]/g, '').replace(/(\..*)\./g, '$1');" );" ></p>
<p>Результат:<input type="text" id="total2" value="0" disabled></p>
</form>
</div>
</div>
</div>