From 1ec8350aab587f1e4bcb0c4a91b2078fbcbe9eb6 Mon Sep 17 00:00:00 2001 From: Catalin Date: Fri, 2 Aug 2024 15:31:45 +0300 Subject: [PATCH] HDX-10024 disable submit button if fields are empty --- .../fanstatic/landing_pages/hdx_signals.js | 15 +++++++++++++-- .../templates/landing_pages/signals.html | 9 +++++---- 2 files changed, 18 insertions(+), 6 deletions(-) diff --git a/ckanext-hdx_theme/ckanext/hdx_theme/fanstatic/landing_pages/hdx_signals.js b/ckanext-hdx_theme/ckanext/hdx_theme/fanstatic/landing_pages/hdx_signals.js index 17927ad3b2..f8ce10af1f 100644 --- a/ckanext-hdx_theme/ckanext/hdx_theme/fanstatic/landing_pages/hdx_signals.js +++ b/ckanext-hdx_theme/ckanext/hdx_theme/fanstatic/landing_pages/hdx_signals.js @@ -1,6 +1,8 @@ $(document).ready(function () { - var $form = $('#mc_embed_signup form'); + + var $form = $('#signals-form-card form'); var $button = $form.find('#mc-embedded-subscribe'); + var $fields = $form.find('#mce-EMAIL, #mce-FNAME, #mce-ORG'); var DATASETS_GROUPS = [ '[4389]' @@ -105,7 +107,11 @@ $(document).ready(function () { return $form.find('input[name^="group' + group + '"]:checked').length > 0; }); - if(dataset_checked && location_checked) { + var fields_filled = $fields.toArray().every(function(field) { + return $(field).val().trim() !== ''; + }); + + if(dataset_checked && location_checked && fields_filled) { $button.removeClass('disabled').removeAttr('disabled'); } else { @@ -142,4 +148,9 @@ $(document).ready(function () { disable_submit_button(); }); }); + + $fields.on('input', function() { + disable_submit_button(); + }); + }); diff --git a/ckanext-hdx_theme/ckanext/hdx_theme/templates/landing_pages/signals.html b/ckanext-hdx_theme/ckanext/hdx_theme/templates/landing_pages/signals.html index 2f4d6d0241..b9724940eb 100644 --- a/ckanext-hdx_theme/ckanext/hdx_theme/templates/landing_pages/signals.html +++ b/ckanext-hdx_theme/ckanext/hdx_theme/templates/landing_pages/signals.html @@ -30,7 +30,7 @@
-
+
@@ -353,9 +353,10 @@
- +