Skip to content

Commit

Permalink
HDX-10024 disable submit button if fields are empty
Browse files Browse the repository at this point in the history
  • Loading branch information
ccataalin committed Aug 2, 2024
1 parent 0575340 commit 1ec8350
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 6 deletions.
Original file line number Diff line number Diff line change
@@ -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]'
Expand Down Expand Up @@ -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 {
Expand Down Expand Up @@ -142,4 +148,9 @@ $(document).ready(function () {
disable_submit_button();
});
});

$fields.on('input', function() {
disable_submit_button();
});

});
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
</div>
<div class="row">
<div class="col-12">
<div class="bem-card card my-3">
<div class="bem-card card my-3" id="signals-form-card">
<div class="card-body bem-card__body">
<div class="row">
<div class="col-12 col-md-10 col-lg-8 mx-auto">
Expand Down Expand Up @@ -353,9 +353,10 @@
<input type="text" name="b_ea3f905d50ea939780139789d_e908cb9d48" tabindex="-1" value="">
</div>
<div class="clear text-center mb-3">
<input type="submit" name="subscribe" id="mc-embedded-subscribe" class="btn btn-primary"
data-module="hdx_click_stopper" data-module-link_type="signals sign up"
data-module-just_send_event="true" data-module-label="Subscribe" value="Subscribe">
<input type="submit" name="subscribe" id="mc-embedded-subscribe"
class="btn btn-primary disabled" disabled data-module="hdx_click_stopper"
data-module-link_type="signals sign up" data-module-just_send_event="true"
data-module-label="Subscribe" value="Subscribe">
</div>
</div>
</form>
Expand Down

0 comments on commit 1ec8350

Please sign in to comment.