JS respects formnorequired

This commit is contained in:
Felix Hamann 2018-06-30 23:05:34 +02:00
parent eb7f971d10
commit 62b708438c
2 changed files with 10 additions and 3 deletions

View File

@ -13,6 +13,7 @@
.alerts {
top: 150px;
bottom: auto;
}
}

View File

@ -10,6 +10,12 @@
if (requireds.length == 0) {
return false;
}
if (typeof button.dataset.formnorequired !== 'undefined' && button.dataset.formnorequired !== null) {
button.addEventListener('click', function() {
form.submit();
});
return false;
}
updateButtonState();
requireds.forEach(function(el) {
@ -66,10 +72,10 @@ document.addEventListener('DOMContentLoaded', function() {
var forms = document.querySelectorAll('form');
Array.from(forms).forEach(function(form) {
// auto reactiveButton submit-buttons with required fields
var submitBtn = form.querySelector('[type=submit]');
if (submitBtn) {
var submitBtns = Array.from(form.querySelectorAll('[type=submit]'));
submitBtns.forEach(function(submitBtn) {
window.utils.reactiveButton(form, submitBtn, validateForm);
}
});
// auto conditonal fieldsets
var fieldSets = Array.from(form.querySelectorAll('fieldset[data-conditional-id][data-conditional-value]'));