https://github.com/struttower/disable-form-on-submit
JavaScript plug-in that can disable a form for a specific amount of time after a submit is attempted
https://github.com/struttower/disable-form-on-submit
html-form javascript javascript-plugin
Last synced: 2 months ago
JSON representation
JavaScript plug-in that can disable a form for a specific amount of time after a submit is attempted
- Host: GitHub
- URL: https://github.com/struttower/disable-form-on-submit
- Owner: StrutTower
- License: mit
- Created: 2018-02-08T23:08:08.000Z (almost 8 years ago)
- Default Branch: master
- Last Pushed: 2023-11-19T00:30:01.000Z (about 2 years ago)
- Last Synced: 2025-08-29T16:37:38.990Z (4 months ago)
- Topics: html-form, javascript, javascript-plugin
- Language: JavaScript
- Homepage: https://struttower.github.io/disable-form-on-submit/demo/demo.html
- Size: 19.5 KB
- Stars: 1
- Watchers: 1
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Disable Form on Submit
JavaScript plug-in that can disable a from for a specific amount of time after a submit is attempted.
Great for preventing users from double clicking on the submit button and submitting the form twice.
[Live Demo](https://struttower.github.io/disable-form-on-submit/demo/demo.html)
## Usage
Basic usage with default options:
```javascript
new disableFormOnSubmit(formElement);
```
With Options:
```javascript
new disableFormOnSubmit(formElement, {
duration: 4000,
buttonTemplate: 'Please Wait...',
submitInputText: 'Please Wait...'
});
```
## Options
| Option | Description |
|:------:|-------------|
| duration | Time that the form is disabled in milliseconds. Default: 4000 |
| buttonTemplate | HTML that will replace the content of any submit buttons while the form is disabled. false will disable the replacement. Default: `'Please Wait...'` |
| submitInputText | Text that will replace the value of any submit inputs while the form is disabled. false will disable the replacement. Default: `'Please Wait...'`
### Override the duration on a specific form
If your are using a selector that selects multiple forms the duration can be overriden on a specific form by adding a
`data-disable-duration` attribute to the form:
```html
```
### Disable on a specific form using data attributes
```html
```