I want to enable and disable the boot buttons. There are 4 buttons on the page, when loading the 1st button is on, and rest is off. Now, when I press button1, the rest of the button should be turned on and button1 disabled.
Below my code, it can turn off the first button, but the rest button is not turned on.
$('document').ready(function() {
$("#add_resume1").on("submit", function(e) {
e.preventDefault;
var btn = $('#btn-save1');
$.ajax({
type: 'post',
url:$('form#add_resume1').attr('action'),
cache: false,
dataType: 'json',
data: $('form#add_resume1').serialize(),
beforeSend: function() {
$("#validation-errors").hide().empty();
},
success: function(data) {
if(data.success == false) {
var arr = data.errors;
$.each(arr, function(index, value) {
if (value.length != 0) {
$("#validation-errors").append('<div class="alert alert-danger"><strong>'+ value +'</strong><div>');
$('#basicdetails').val('');
$('#button.disabled[disabled=disabled]')
.removeClass('disabled')
.prop('disabled', false);
}
});
$("#validation-errors").show();
btn.button('reset');
} else {
$("#success").html('<div class="alert alert-success">Basic details saved successfully.<div>');
$('#basicdetails').val('');
$('#btn-save1').prop('disabled', true);
$('#button.disabled[disabled=disabled]')
.removeClass('disabled')
.prop('disabled', false);
}
},
error: function(xhr, textStatus, thrownError) {
alert(thrownError);
btn.button('reset');
}
});
return false;
});
});
Thanks for the tips.
Edit
<button type="submit" class="btn btn-home" name= "btn-save5" id= "btn-save5" disabled="disabled" required="required">Save</button>
This is the button code in the html file. The html file is quite large. So, I just give you the button code. btn-save5, btn-save4, btn-save3m is similar to this.
source
share