I'm building a form.
I have two input fields (#totalIncome and #totalExpenses). I need to confirm that the value of those two fields equal the equation #totalIncome > #totalExpenses before the user will be able to send the form. I'm struggling with the jQuery.
If #totalIncome isn't greater than #totalExpenses I want to display an error message in the #validation div (for this example it should display "Income is lower than expenses"). I also want to disable the submit button, #submit-suggestion.
If #totalIncome actually is greater than #totalExpenses I simply want the #submit-suggestion-button to be functional.
This is my code so far:
$('#validation').change(function() {
if ($('#totalIncome').val() < $('#totalExpenses').val()) {
$('#validation').val('Income is lower than expenses.')
$('#submit-suggestion').prop("disabled", true);
} else {
$('#submit-suggestion').prop("disabled", false);
}
});