person: avoid js error when personAcceptEmail is null

This commit is contained in:
nobohan 2021-11-08 11:04:20 +01:00
parent bddcdd7de2
commit 1dbf29beea

View File

@ -7,7 +7,6 @@ const personAcceptEmail = document.getElementById("personAcceptEmail");
const personPhoneNumber = document.getElementById("personPhoneNumber");
const personAcceptSMS = document.getElementById("personAcceptSMS");
new ShowHide({
froms: [maritalStatus],
container: [maritalStatusDate],
@ -24,21 +23,24 @@ new ShowHide({
event_name: 'change'
});
new ShowHide({
froms: [personEmail],
container: [personAcceptEmail],
test: function(froms) {
for (let f of froms.values()) {
for (let input of f.querySelectorAll('input').values()) {
if (input.value) {
return true
if (personAcceptEmail) {
new ShowHide({
froms: [personEmail],
container: [personAcceptEmail],
test: function(froms) {
for (let f of froms.values()) {
for (let input of f.querySelectorAll('input').values()) {
if (input.value) {
return true
}
}
}
}
return false;
},
event_name: 'input'
});
return false;
},
event_name: 'input'
});
}
new ShowHide({
froms: [personPhoneNumber],