Adds conditional formatting to a squarespace form
Tue Aug 27 2024 16:48:49 GMT+0000 (Coordinated Universal Time)
Saved by
@defymavity
#javascript
<!-- Squarepaste Form Logic © -->
<script src="https://storage.googleapis.com/squarepaste/base-jquery.js"></script>
<script type="text/javascript">
/* Select Field */
$(document).on('change', '#select-6ed7f446-8ef8-42ea-abf4-e72a84b41cb3-field select', function() {
const value = $(this).val();
if (value == 'Yes') {
$('#section-8ce22bc1-00cb-43c0-b3ab-cccaab43ad22').fadeIn();
}
else {
$('#section-8ce22bc1-00cb-43c0-b3ab-cccaab43ad22').hide();
}
});
/* Radio Field- Hide submit button based on radio button selection and display message */
$(document).on('change', 'input[type="radio"]', function() {
if ($('input[type="radio"][value="No"]:checked').length > 0) {
$('button[type="submit"]').fadeIn();
$('#section-26b8b3d8-8295-42a8-bae3-3f26b85de441').hide();
} else if ($('input[type="radio"][value="No"]:checked').length === 0) {
$('button[type="submit"]').hide();
$('#section-26b8b3d8-8295-42a8-bae3-3f26b85de441').fadeIn();
} else {
$('button[type="submit"]').hide();
}
});
// Trigger the change event on page load to set initial state
$('input[type="radio"]:checked').change();
</script>
content_copyCOPY
works great on encompass family services.
originally used code from SquarePaste and had to manipulate it for my needs.
Comments