Last active
May 2, 2017 03:40
-
-
Save brooke-heaton/b03affc48cdb6794370f3010347b468e to your computer and use it in GitHub Desktop.
Conditionally Hide Subfields in Drupal 8 Webform Address Elements
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
(function ($, Drupal) { | |
'use strict'; | |
Drupal.behaviors.registration_form = { | |
attach: function (context) { | |
// Conditionally hide the city/state unless user chooses United States. | |
$("#edit-address-country").change(function () { | |
if ($("#edit-address-country").val() === "United States") { | |
$('.form-item-address-city').show(); | |
$('.form-item-address-state-province').show(); | |
} | |
else { | |
$('.form-item-address-city').hide(); | |
$('.form-item-address-state-province').hide(); | |
} | |
}); | |
} | |
} | |
}(jQuery, Drupal)); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment