Validation of one field based on another

I am trying to build out an Ajax event to validate data entry on a control form. The form allows users to update inventory amounts in the field. The field I want to validate is the {reason} field (integer, values <= 24 indicate negative). The quantity field is where the user enters the amount of units to adjust. This number is generally a negative as product is perishable and might die or be diseased, however the number can be positive for reasons like a recount or correction of a previous count.

I am using an Ajax event on the change of the reason field (radio select with integer values representing the reasons) If the reason id is less than 24, a negative number is expected, otherwise the value can be positive. If the conditions are met, I want to give them an alert to make the change appropriately. Here is what I wanted to use:

$q = {quantity};
$r = {reason};

if({quantity}> 0 and {reason} <= 24) {

sc_alert("The value you entered is positive but the reason indicates a negative value");
}

As it currently stands, nothing happens when a positive number is entered with a reason code <= 24. I hope this is something I am missing, but I can’t seem to find it.