Disable Submit Button Upon Form Submission
Multiple clicks on a "Submit" button can cause duplicate processing if your programming is slow or the user's connection is lagging. Duplicate processing can include duplicate database records, multiple emails, or different types of errors. JavaScript provides an easy way to disable the multiple submission of a form once the form has been submitted.
The Code
In the HTML, use the following "onsubmit" information:
It's important to trigger the even on form submission -- not everyone clicks the "submit" button. You will also need to give your submit button the submit_button ID attribute.
![Introducing MooTools Templated]()
One major problem with creating UI components with the MooTools JavaScript framework is that there isn't a great way of allowing customization of template and ease of node creation. As of today, there are two ways of creating:
new Element Madness
The first way to create UI-driven...
![Chris Coyier’s Favorite CodePen Demos]()
David asked me if I'd be up for a guest post picking out some of my favorite Pens from CodePen. A daunting task! There are so many! I managed to pick a few though that have blown me away over the past few months. If you...
![jQuery Link Nudge Plugin]()
A while back I debuted a tasteful mouseover/mouseout technique called link nudging. It started with a MooTools version and shortly thereafter a jQuery version. Just recently Drew Douglass premiered a jQuery plugin that aimed at producing the same type of effect.
![Introducing MooTools ScrollSidebar]()
How many times are you putting together a HTML navigation block or utility block of elements that you wish could be seen everywhere on a page? I've created a solution that will seamlessly allow you to do so: ScrollSidebar. ScrollSidebar allows you...
As an aside, if you’re also using any javascript validation, disable the submit button only after you’ve passed the validation tests.
Also, if the form is output programattically and the results stored in a DB, you can incorporated a unique hidden value in the form and redirect to an error page on duplicate submission detection.
Great tips (and name) Dave!
I’ve never been a fan of “disabling” elements on a website, but if it can save a developer lots of cleanup in the long run, I say do it.
How would you write a code to “redirect to an error page on duplicate submission detection.”
oh, and my middle name is David. It may not be Dave but it is pretty close. :D
thanks for the tip… might also be a good idea to apply some sort of visual display so your users know the server is working. :)
Hi David,
I’m having a really hard time trying to disable a submit (IMAGE) button when the page is submitted in APEX 3.2.
I cannot get the SUBMIT button to disable itself. Somehow this only works on HTML Buttons rather than IMAGES from CSS Templates.
Would appreciate it if you could suggest an alternative.
Thanks.
Great way of prevention. Thanks a lot. I just implemented it on one of my websites.
Does anyone have a unit test code for testing the submit button disabled when click it?
Thank boss..u saved my time
i can’t disable the submit button because i have some validation before page submit.if the validation failed the button is permanently disabled please some one assist