I need to use the same code in different jQuery attributes. Is it possible to put this if in a external function and call it inside a change event? I would like avoid duplicating code.
$("#Max").change(function () {
var max = $("#Max").val();
var min = $("#Min").val();
if (max != min) {
$("#Result").attr("disabled", "disabled");
}
else {
$("#Result").removeAttr("disabled");
}
});
$("#Min").change(function () {
var max = $("#Max").val();
var min = $("#Min").val();
if (max != min) {
$("#Result").attr("disabled", "disabled");
}
else {
$("#Result").removeAttr("disabled");
}
});