Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature request: Add ability to disable submit button upon submitting a form #41053

Open
2 tasks done
alhernandez25 opened this issue Nov 23, 2024 · 1 comment
Open
2 tasks done

Comments

@alhernandez25
Copy link

alhernandez25 commented Nov 23, 2024

Prerequisites

Proposal

When a button has a type of "submit" and is inside a form like such:

<form action="/action_page.php" method="get">
     ...
     <button type="submit" class="btn btn-primary" value="Submit">Submit</button>
</form>

Disable the button upon form submission, if possible. Maybe there could be a special bootstrap tag to add to the button such as "data-bs-disable-on-submit" and it would only work if the button is inside a form.

Motivation and context

When submitting a form with a button, I noticed that there is nothing preventing the user from continuously pressing the same button, which could cause issues from the multiple form submissions. Admittedly, this is not a huge issue, as one could probably catch the form submission event with javascript and disable the button, but it would still be a decent feature to add for developers such as myself that try to keep their code as clean and simple as possible by using all the available Bootstrap tags and classes to limit the amount of extra javascript or css needed.

@julien-deramond
Copy link
Member

Hello @alhernandez25,

Thanks for the suggestion! I'll let other maintainers share their thoughts, but I believe this behavior falls outside the scope of Bootstrap. It's aligned with the default behavior of native HTML forms, and Bootstrap's role is generally focused on providing minimal JavaScript enhancements.

This specific use case can be addressed quite easily on the client side by listening for the submit event, identifying the button, and applying the disabled state as needed. While it’s a valid concern, managing form submission logic is typically left to the application layer rather than the framework itself.

Looking forward to hearing other perspectives!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants