Хм, сам же и решил :)
document.addEventListener("DOMContentLoaded", function () {
let inputs = document.getElementsByTagName("input");
let selects = document.getElementsByTagName("select");
let select = document.getElementById("shopAddress");
let element = document.getElementById("newAddress");
let myCollapse = new bootstrap.Collapse(element, {toggle: false});
select.addEventListener("change", function () {
if (select.options[select.selectedIndex].value === 'new') {
for (let x of inputs) {
if (x.parentElement.parentElement === element) {
x.setAttribute('required', '');
}
}
for (let y of selects) {
if (y.parentElement.parentElement === element) {
y.setAttribute('required', '');
}
}
myCollapse.show();
} else {
for (let z of inputs) {
if (z.parentElement.parentElement === element) {
z.removeAttribute('required');
}
}
for (let i of selects) {
if (i.parentElement.parentElement === element) {
i.removeAttribute('required');
}
}
myCollapse.hide();
}
});
});