v0.1

Campos personalizados
#99 - Entradas de archivos personalizadas
Convierta cualquier cosa en un archivo de entrada
Cree formularios condicionales mostrando y ocultando las entradas requeridas.
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>verdaderoAdd these data attributes to your HTML elements in Webflow. For example: <div data-attribute="value">
More scripts in Conditional Visibility