$("#calculate").click(function(){ var n = $('#n').val(); var computation1 = factorial(n-1); var computation2 = (computation1 * 1.0) / 2; $('#result').html('Case 1: ' + computation1 + '
' + 'Case 2: ' + computation2); }); $("input").change(function(){ var isInvalid = $('#nDiv').hasClass('is-invalid') || $('#rDiv').hasClass('is-invalid') || $('#RDiv').hasClass('is-invalid'); if(isInvalid){ $("#calculate").prop("disabled", true); }else{ $("#calculate").removeAttr('disabled'); } });
Number required!