Introducing ReUI:Open-source UI components and apps built with React, Next.js and Tailwind CSS
Browse ReUI

Submit form in stepper not working


I have the following code from create-app.js. How to modify the code so that the form will be submitted to server side upon clicking the submit button.


formSubmitButton.addEventListener("click", function (e) {
// Validate form before change stepper step
var validator = validations[2]; // get validator for last form

validator.validate().then(function (status) {
formSubmitButton.disabled = false;

if (status == "Valid") {

// Prevent default button action
e.preventDefault();

// Disable button to avoid multiple click
formSubmitButton.disabled = true;

// Show loading indication
formSubmitButton.setAttribute("data-kt-indicator", "on");

// Simulate form submission
setTimeout(function() {
// Hide loading indication
formSubmitButton.removeAttribute("data-kt-indicator");

// Enable button
formSubmitButton.disabled = false;
$( "#create_new_bo" ).submit();
}, 2000);



} else {
Swal.fire({
text: "Sorry, looks like there are some errors detected, please try again.",
icon: "error",
buttonsStyling: false,
confirmButtonText: "Ok, got it!",
customClass: {
confirmButton: "btn btn-light"
}
}).then(function () {
KTUtil.scrollTop();
});
}
});
});


Text formatting options
Submit
Here's a how to add some HTML formatting to your comment:
  • <pre></pre> for JS codes block
  • <pre lang="html"></pre> for HTML code block
  • <pre lang="scss"></pre> for SCSS code block
  • <pre lang="php"></pre> for PHP code block
  • <code></code> for single line of code
  • <strong></strong> to make things bold
  • <em></em> to emphasize
  • <ul><li></li></ul>  to make list
  • <ol><li></li></ol>  to make ordered list
  • <h3></h3> to make headings
  • <a></a> for links
  • <img> to paste in an image
  • <blockquote></blockquote> to quote somebody
  • happy  :)
  • shocked  :|
  • sad  :(

Replies (8)


Your blog post was exactly what I needed today. Thank you for providing such valuable information in such an engaging way.
Delhi Escorts



With Sprunki Game - Play Online Incredibox Mod, digital music creation becomes an adventure. Featuring entertaining characters, dynamic beats, and eye-catching visuals, it’s designed to let users of any skill level explore rhythm and melody in an interactive way. Sprunki Mode



Hi,

You should use the form object and call it's submit method form.submit() as shown below:

Replace the below demo timeout code to similate the form processing:

// Simulate form submission
setTimeout(function() {
// Hide loading indication
formSubmitButton.removeAttribute("data-kt-indicator");

// Enable button
formSubmitButton.disabled = false;

stepperObj.goNext();
}, 2000);


With the below actual code:

// Hide loading indication
formSubmitButton.removeAttribute("data-kt-indicator");

// Enable button
formSubmitButton.disabled = false;

stepperObj.goNext();

form.submit();


Regards.



Thank you Sean!. You saved my life. All good now.



Always glad to help you happy


Your Support Matters!

We will highly appreciate your Metronic Review on Themeforest.
Please go to Themeforest Downloads page, select Metronic & leave your feedback.

Your content is a breath of fresh air—so clear and well-written. I really appreciate how you break down the details. Thanks a lot for making this so readable! Madhur Day



I tried $( "#create_new_bo" ).submit(); but it does not work


Text formatting options
Submit
Here's a how to add some HTML formatting to your comment:
  • <pre></pre> for JS codes block
  • <pre lang="html"></pre> for HTML code block
  • <pre lang="scss"></pre> for SCSS code block
  • <pre lang="php"></pre> for PHP code block
  • <code></code> for single line of code
  • <strong></strong> to make things bold
  • <em></em> to emphasize
  • <ul><li></li></ul>  to make list
  • <ol><li></li></ol>  to make ordered list
  • <h3></h3> to make headings
  • <a></a> for links
  • <img> to paste in an image
  • <blockquote></blockquote> to quote somebody
  • happy  :)
  • shocked  :|
  • sad  :(
Text formatting options
Submit
Here's a how to add some HTML formatting to your comment:
  • <pre></pre> for JS codes block
  • <pre lang="html"></pre> for HTML code block
  • <pre lang="scss"></pre> for SCSS code block
  • <pre lang="php"></pre> for PHP code block
  • <code></code> for single line of code
  • <strong></strong> to make things bold
  • <em></em> to emphasize
  • <ul><li></li></ul>  to make list
  • <ol><li></li></ol>  to make ordered list
  • <h3></h3> to make headings
  • <a></a> for links
  • <img> to paste in an image
  • <blockquote></blockquote> to quote somebody
  • happy  :)
  • shocked  :|
  • sad  :(