html5 - Set the min value of input type number to value of other input type number -


i have html code

<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> 

if type 1000 on id="amount", id="cash" min 1000.

but doesn't work.

the straightforward way add onchange handler payment input, such as:

<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..."          onchange="document.getelementbyid('cash').min=this.value;"/>     <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> 

this gets functionality looking without needing include third party library jquery.


Comments

Popular posts from this blog

java - Date formats difference between yyyy-MM-dd'T'HH:mm:ss and yyyy-MM-dd'T'HH:mm:ssXXX -

c# - Get rid of xmlns attribute when adding node to existing xml -