The New Way to Build with AI! Introducing ReUI — the developer platform for agentic UI with shadcn/ui
Browse ReUI Pro

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
Click any option to insert into your comment. Select text first to wrap it.
  • **text** to make things bold
  • *text* to emphasize
  • ### Heading to make headings
  • [link text](url) for links
  • ![alt text](image-url) to paste in an image
  • - item to make a list
  • 1. item to make an ordered list
  • > quote to quote somebody
  • `code` for single line of code
  • ```js ... ``` for JS code block
  • ```html ... ``` for HTML code block
  • ```scss ... ``` for SCSS code block
  • ```php ... ``` for PHP code block
  • --- for a horizontal rule
  • happy  :)
  • shocked  :|
  • sad  :(

Replies (4)

 
Deleted comment
 
Deleted comment
 
Deleted comment

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.
 
Deleted comment

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


Text formatting options
Submit
Click any option to insert into your comment. Select text first to wrap it.
  • **text** to make things bold
  • *text* to emphasize
  • ### Heading to make headings
  • [link text](url) for links
  • ![alt text](image-url) to paste in an image
  • - item to make a list
  • 1. item to make an ordered list
  • > quote to quote somebody
  • `code` for single line of code
  • ```js ... ``` for JS code block
  • ```html ... ``` for HTML code block
  • ```scss ... ``` for SCSS code block
  • ```php ... ``` for PHP code block
  • --- for a horizontal rule
  • happy  :)
  • shocked  :|
  • sad  :(
Text formatting options
Submit
Click any option to insert into your comment. Select text first to wrap it.
  • **text** to make things bold
  • *text* to emphasize
  • ### Heading to make headings
  • [link text](url) for links
  • ![alt text](image-url) to paste in an image
  • - item to make a list
  • 1. item to make an ordered list
  • > quote to quote somebody
  • `code` for single line of code
  • ```js ... ``` for JS code block
  • ```html ... ``` for HTML code block
  • ```scss ... ``` for SCSS code block
  • ```php ... ``` for PHP code block
  • --- for a horizontal rule
  • happy  :)
  • shocked  :|
  • sad  :(
buy metronic keenthemes mega bundle

ReUI

Open-source React components, blocks and templates built on shadcn/ui and Tailwind CSS by Keenthemes.