Skip to content

jQuery plugin to stop double-clicks from submitting forms multiple times

Notifications You must be signed in to change notification settings

steveosoule/jquery.debounceSubmit

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 

Repository files navigation

$.fn.debounceSubmit

jQuery plugin to stop double-clicks from submitting forms multiple times.

Description

After a form is submitted, this plugin will disable it for 750 milliseconds to prevent duplicate form submits. After the 750 millisecond wait the form will be re-enabled (This is important if some one uses "Esc" to stop a form submit from completing)

Example Usage

$('form').debounceSubmit(); // Applies to all forms
$('#payment-form').debounceSubmit(); // Applies to #payment-form
$('#another-payment-form').debounceSubmit({
  wait: 500
});

Options

  • wait: (Number, Default: 750) The amount of time (in milliseconds) between when the form is disabled and when it is re-enabled
  • debug: (Boolean, Default: false) Enable/Disable console.logs() for submit handler being enabled, disabled, & prevented

Real Life Example

Before

Clicking the submit button multiple times causes the form to make several partial/canceled requests to the server that result in a tax calculation error during checkout

Before Submit Once

After

Clicking the submit button multiple times only allows one successfull submit to happen

After Submit Once

About

jQuery plugin to stop double-clicks from submitting forms multiple times

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published