---
# Submit button withdrawal
**URL:** https://modul-r.codekraft.it/2021/08/submit-button-withdrawal/
Date: 2021-08-19
Author: Erik
Post Type: post
Summary: you can enable the send withdrawal of the form (like in gmail) and abort the submission. Add this code to functions.php ref. https://wordpress.org/support/topic/withdrawal-button/ Your name Your email Subject Your message (optional)
Categories: Blog, Contact form 7
---
you can enable the send withdrawal of the form (like in gmail) and abort the submission. Add this code to functions.php
ref. https://wordpress.org/support/topic/withdrawal-button/
```
var delay = 2000; // set the preferred delay before send email
var interval = null; // don't touch this
jQuery(function ($) {
// displays the button in active state
function sendDisplayON(btn) {
btn.val("Abort?");
btn.addClass("submitting");
$(btn).siblings(".ajax-loader").css("visibility", "visible");
}
// displays the button in normal state
function sendDisplayOFF(btn) {
btn.val("Send");
btn.removeClass("submitting");
$(btn).siblings(".ajax-loader").css("visibility", "hidden");
}
// on submit
$('.wpcf7 input[type="submit"]').on("click", function (e) {
e.preventDefault(); // prevent form submit
var btn = $(this); // store this button into a variable
if (btn.hasClass("submitting")) {
clearInterval(interval); // reset the timeout
sendDisplayOFF(btn);
} else {
sendDisplayON(btn);
interval = setInterval(function () {
// waits delay var value then will trigger this function
clearInterval(interval); // reset the timeout
sendDisplayOFF(btn);
wpcf7.submit(btn.closest("form")[0]); // non ajax forms -> btn.closest("form")[0].submit;
}, delay);
}
});
});
```
---
## Categories
- Blog
- Contact form 7
---
## Navigation
- [Home](https://modul-r.codekraft.it/)
- [Theme Setup](https://modul-r.codekraft.it/2019/06/theme-setup/)
- [Environment Setup](https://modul-r.codekraft.it/2019/06/environment-setup/)
- [Functions and Components](https://modul-r.codekraft.it/2019/06/custom-theme-functions/)
- [Classic](https://modul-r.codekraft.it/category/classic/)
- [Shop](https://modul-r.codekraft.it/shop/)
- [Tag /Archive format](https://modul-r.codekraft.it/tag/post-formats/)
- [Modul R](https://wordpress.org/themes/modul-r/)
- [Modul R (git)](https://github.com/erikyo/Modul-R)
- [Modul R Child (git)](https://github.com/erikyo/Modul-R-child)
- [CF7 Antispam](https://wordpress.org/plugins/cf7-antispam/)
- [OH-MY-SVG](https://modul-r.codekraft.it/oh-my-svg/)
- [Model-Viewer WordPress block](https://modul-r.codekraft.it/model-viewer-wordpress-block/)
- [Remove Capslock](https://wordpress.org/plugins/remove-capslock)
- [Blog](https://modul-r.codekraft.it/category/random-access-memories/)
- [Codekraft](https://github.com/codekraft-studio)
- [About Me](https://modul-r.codekraft.it/erik-golinelli/)
- [Contact](https://modul-r.codekraft.it/contacts/)
- [Credits](https://modul-r.codekraft.it/credits/)
---
## Footer Links
- [Theme Setup](https://modul-r.codekraft.it/2019/06/theme-setup/)
- [Functions and Components](https://modul-r.codekraft.it/2019/06/custom-theme-functions/)
- [Environment Setup](https://modul-r.codekraft.it/2019/06/environment-setup/)
- [Download](https://wordpress.org/themes/modul-r/)
- [Contact form 7](https://modul-r.codekraft.it/category/contact-form-7/)
- [Quick Start](https://modul-r.codekraft.it/category/quick-start/)
- [Classic](https://modul-r.codekraft.it/category/classic/)
- [Post Formats](https://modul-r.codekraft.it/category/post-formats/)
- [Block](https://modul-r.codekraft.it/category/block/)
- [Clothing](https://modul-r.codekraft.it/product-category/clothing/)
- [Privacy Policy](https://modul-r.codekraft.it/privacy-policy/)
- [Proudly powered by WordPress & made in Bologna with ♥ by Codekraft](https://codekraft.it/)