Yeah Cool Yeah Cool - 3 months ago 19
jQuery Question

JavaScript Button disabled Value?

Is it possible the button disabled if the bank balance is too small?
Example: Bank balance = 3 And the Button Bank Balance = 5 <- so the button is disabled

so you need a enough money that the button not disabled is!

I hope you understand what I mean and hope you can help me!

My Button :

<button type="sumbit" name='einzahlen' class="btn btn-info btn-block btn-md">Pin einlösen</button>

Answer

Check this simple code in jQuery, Hope this helps you!

$(document).ready(function(){
    $('#chk').click(function(){
        var bal = parseFloat ($('.balance').text());
        if(bal <= 50){
	   $('#btn').attr('disabled','disabled');
        }
    });
});
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<button type="sumbit" name='einzahlen' class="btn btn-info btn-block btn-md" id="btn">Pin einlösen</button>
<button id="chk">Check balance</button>
<span>Balance: </span><span class="balance">50</span>

Comments