Newbie here. Hello, my target is when error shows up (Not enough balance), the INSERT button will be disabled. I have a input type number whose value must be less than equal to the current wallet, If it's greater than, then error will appear. I have provided the snippet below.
SCRIPT:
$( document ).ready(function() {
$("#box").keyup( function(){
var betAmount = $("#box").val();
var walletAmount = 500; // your session data goes here
var remainingAmount = walletAmount - betAmount;
$("#betAmountResult").text(remainingAmount >=0 ? remainingAmount : 'Error, not enough balance');
})
});
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.4.1/js/bootstrap.min.js"></script>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"> </script>
<form method="POST" action="<?php echo base_url();?>auth/form_validation">
<input type="number" placeholder="Enter Amount" name="bet" class="form-control" id="box" required>
<!-- change id's name to betAmount -->
<p>CURRENT WALLET: <a style="color:blue;">500</a></p>
<p class="remaining">REMAINING BALANCE:
<a class="p-1" id="betAmountResult"></a></p>
<input type="submit" name="insert" value="Insert">
</div>
</form>