Im validating the email in my form with jquery 3.3.1 , but when i tried to remove the disabled attribute from the form submit button, it doesnt do anything... i mean, it only disable the button if the response is true.. but when the response is false, it doesnt remove the attribute. also it doesnt change the css color to green... the password matcher works fine, but the email its not going anywhere sadly. any chance to help me to see whats wrong here?
this is the code
$(document).ready(function () {
$('#registerform').validate();
$('#password, #confirmpassword').on('keyup', function () {
if ($('#password').val() == $('#confirmpassword').val()) {
$('#alertPassword').html('<li><i class="fa fa-check text-success"></i> Password matching</li>').css('color', 'green');
$("#submitsn").attr("disabled", false);
} else {
$('#alertPassword').html('<li><i class="fa fa-times text-success"></i> Password not matching</li>').css('color', 'red');
$("#submitsn").attr("disabled", true);
}
});
$("#email").live("blur", function (e) {
$("#alertBadgeemail").hide();
if ($("#email").val() == null || $("#email").val() == "") {
$("#alertBadgeemail").show();
$("#submitsn").attr("disabled", false);
$("#alertBadgeemail").html("Email is required field.").css("color", "red");
} else {
$.ajax({
type: "POST",
url: "check-email.sn",
data: $('#registerform').serialize(),
dataType: "html",
cache: false,
success: function (msg) {
$("#alertBadgeemail").show();
$("#alertBadgeemail").html(msg).css("color", "red");
$("#submitsn").attr('disabled', 'disabled');
},
error: function (msg) {
$("#alertBadgeemail").show();
$("#alertBadgeemail").html(msg).css("color", "green");
$("#submitsn").removeAttr('disabled', 'disabled');
}
});
}
});
});