@@ -47,6 +47,21 @@ public function output_script() {
4747
4848 var GWDisableSubmit;
4949
50+ function gwDisableSubmitDebounce(func, wait, immediate) {
51+ var timeout;
52+ return function() {
53+ var context = this, args = arguments;
54+ var later = function() {
55+ timeout = null;
56+ if (!immediate) func.apply(context, args);
57+ };
58+ var callNow = immediate && !timeout;
59+ clearTimeout(timeout);
60+ timeout = setTimeout(later, wait);
61+ if (callNow) func.apply(context, args);
62+ };
63+ };
64+
5065 (function($){
5166
5267 GWDisableSubmit = function( args ) {
@@ -88,6 +103,10 @@ public function output_script() {
88103 $(document).on( 'gppa_updated_batch_fields', function() {
89104 self.runCheck();
90105 });
106+ // We listen to input change to cover for more field types, for example, image choice field etc.
107+ gform.addAction( 'gform_input_change', function( elem, formId, fieldId ) {
108+ self.runCheck();
109+ });
91110 // GPPA logic may enable submit button, disable that logic.
92111 gform.addFilter( 'gppa_disable_form_navigation_toggling', function() {
93112 return true;
@@ -97,7 +116,7 @@ public function output_script() {
97116
98117 }
99118
100- self.runCheck = function() {
119+ self.runCheck = gwDisableSubmitDebounce( function() {
101120
102121 var $form = $( '#gform_' + self.formId );
103122 var submitButton = $form.find( 'input[type="submit"], input[type="button"], button[type="submit"]' );
@@ -107,7 +126,7 @@ public function output_script() {
107126 submitButton.attr( 'disabled', true ).addClass( 'gwds-disabled' );
108127 }
109128
110- }
129+ }, 10 );
111130
112131 self.areRequiredPopulated = function() {
113132
0 commit comments