diff --git a/Layout/default/ConstructionConsent/View.php b/Layout/default/ConstructionConsent/View.php index fb643072a..9fb92b145 100644 --- a/Layout/default/ConstructionConsent/View.php +++ b/Layout/default/ConstructionConsent/View.php @@ -1179,22 +1179,25 @@ $pagination_entity_name = "Adressen"; }); $(document).ready(function() { - $('#company').on('input', function() { - if ($(this).val().length > 0) { + function checkRequirements() { + if ($('#company').val().length > 0) { $('#firstname').prop('required', false); $('#lastname').prop('required', false); } else { $('#firstname').prop('required', true); $('#lastname').prop('required', true); } - }); - $('#firstname, #lastname').on('input', function() { if ($('#firstname').val().length > 0 && $('#lastname').val().length > 0) { $('#company').prop('required', false); } else { $('#company').prop('required', true); } + } + checkRequirements(); + + $('#company, #firstname, #lastname').on('input change', function() { + checkRequirements(); }); const urlParams = new URLSearchParams(window.location.search);