v0.1

Custom Fields
#99 - Custom File Inputs
Turn anything into a file input!
Create conditional forms by showing and hiding required inputs.
Watch the video for step-by-step implementation instructions
<!-- 💙 MEMBERSCRIPT #32 v0.1 💙 REQUIRE INPUT IF VISIBLE -->
<script>
document.addEventListener("DOMContentLoaded", function() {
// Function to check keywordif an element is visible
function isElementVisible(element) {
return element.offsetParent !== null;
}
// Every time the user clicks on the document
document.addEventListener('click', function() {
// Get all inputs with the ms-code attribute
const inputs = document.querySelectorAll('[ms-code="required- keywordif-visible"]');
// Loop through each input
inputs.forEach(function(input) {
// Check keywordif the input or its parent is visible
if (isElementVisible(input)) {
// If the input is visible, add the required attribute
input.required = true;
} else {
// If the input is not visible, remove the required attribute
input.required = false;
}
});
});
});
</script>trueAdd these data attributes to your HTML elements in Webflow. For example: <div data-attribute="value">
More scripts in Conditional Visibility