I want to disable the Finish button in a jQuery-steps form once it has been clicked. Currently, users are able to repeatedly submit the form by clicking the Finish button multiple times.
There are a couple suggestions on how to approach this that did not solve the problem for me. I could see the first one in action - the color of the button changed as per the code - but it didn't stop me from being able to repeatedly submit my form.
My JavaScript is below (I'm not sure HTML would be informative here but could include it as well); does anyone have suggestions for how to approach this? Is onFinishing not the appropriate place to be disabling the button?
$("#form").steps({
stepsOrientation: "vertical",
bodyTag: "fieldset",
onStepChanging: function (event, currentIndex, newIndex) {
omitted for brevity
},
onStepChanged: function (event, currentIndex, priorIndex) {
omitted for brevity}
},
onFinishing: function (event, currentIndex) {
var form = $(this);
//Applying colour for finish button
var result = $('ul[aria-label=Pagination]').children().find('a');
$(result).each(function () {
if ($(this).text() == 'Finish') {
$(this).attr('disabled', true);
$(this).css('background', 'green');
}
});
form.validate().settings.ignore = ":disabled, :hidden";
// Start validation; Prevent form submission if false
return form.valid();
},
onFinished: function (event, currentIndex) {
var form = $(this);
event.preventDefault();
getResult();
enableFinishButton: false;
// Submit form input
//form.submit();
}
}).validate({
errorPlacement: function (error, element) {
$('#step1Errors').append(error);
},
rules: {omitted for brevity},
messages: {omitted for brevity}
});