Created
August 5, 2019 14:37
-
-
Save Shelob9/a97327d76e1806fa58946153b635b0fd to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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