");
// Optionally redirect after a short delay
setTimeout(function() {
window.location.href = "/thank-you/";
}, 2000); // Redirect after 2 seconds
},
error: function (xhr, status, error) {
// Replace the form's content with an error message
console.error("Submission error:", status, error, xhr.responseText);
$("#multiStepForm").html("
An error occurred during submission. Please try again later. If the problem persists, contact support.
");
},
});
} else {
// Form is not valid, Bootstrap's invalid-feedback messages will appear
// No general alert needed here as specific field errors are shown.
}
});
// Function to extract URL parameters and add them as hidden fields
function addUrlParametersAsHiddenFields() {
const urlParams = new URLSearchParams(window.location.search);
const hiddenFieldsContainer = document.getElementById('urlParamsHiddenFields');
for (const [key, value] of urlParams.entries()) {
const input = document.createElement('input');
input.type = 'hidden';
input.name = key;
input.value = value;
hiddenFieldsContainer.appendChild(input);
}
}
// Initialize the form view and add URL parameters
document.addEventListener('DOMContentLoaded', () => {
addUrlParametersAsHiddenFields();
const initialCustomerType = document.querySelector('input[name="customerType"]:checked').value;
customerType = initialCustomerType;
showStep(currentStep);
});
Explore Chery Bronkhortspruit for the latest Chery models, offers, and expert service.