Skip to content

Instantly share code, notes, and snippets.

@Shelob9
Created August 5, 2019 14:37
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Shelob9/a97327d76e1806fa58946153b635b0fd to your computer and use it in GitHub Desktop.
Save Shelob9/a97327d76e1806fa58946153b635b0fd to your computer and use it in GitHub Desktop.
jQuery(document).ready(function($) {
//variable to prevent blocking all
var blockedOnce = false;
$(document).on("cf.ajax.request", function(e, obj) {
//only block submission once
if (!blockedOnce) {
//Make sure window.cf2 is set properly
if (!window.cf2) {
window.cf2 = {};
}
var formId = obj.formIdAttr;
if (!window.cf2[formId]) {
window.cf2[formId] = {};
}
if (!window.cf2[formId].hasOwnProperty("fieldsBlocking")) {
window.cf2[formId].fieldsBlocking = obj.fieldsBlocking || [];
}
//end hacks caused by not paying down this debt before CF Stripe update
//block submission based on a field
window.cf2[formId].fieldsBlocking.push("fld_6866745_1");
//Set flag to prevent recurssion
blockedOnce = true;
//For testing purposes, re-submit in 2 seconds
setTimeout(function() {
//unblock
window.cf2[formId].fieldsBlocking = [];
//resubmit
obj.$form.submit();
}, 2000);
}
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment