I am trying to disable an input when there is a result from database on keyup function. The addClass and removeClass are not working. They simply don't fire. Any help appreciated.
$("#patient_code").keyup(function() {
var patient_code = $(this).val();
var patient_category = $('#patient_category').val();
var medicine_id = $('#medicine').val();
var formData = {
_token: $('[name="csrf_token"]').attr('content'),
patient_code: patient_code,
medicine_id: medicine_id,
patient_category: patient_category
}
$.ajax({
type: "POST",
url: "/medicines/confirmation/checkConfirmation",
data: formData,
dataType: "JSON",
success: function(response) {
if (!jQuery.isEmptyObject(response.confirmation_status)) {
$(".patient_has_confirmationform").show();
$(".selected_patient_code").html(response.confirmation_status[0].patient_code);
//THIS IS NOT FIRING
$(".btnSaveConfirmation").removeClass().addClass("btn btn-borders btn-danger btn-lg disabled").attr("disabled", true);
console.log("there is a result for that patient code ");
} else {
$(".patient_has_confirmationform").hide();
//THIS IS NOT FIRING
$(".btnSaveConfirmation").removeClass().addClass("btn btn-borders btn-success btn-lg").attr("disabled", false);
console.log("there are no results for that patient code ");
}
},
error: function(jqXHR, textStatus, errorThrown, data) {
console.log(jqXHR, textStatus, errorThrown, data);
}
});
});