JS respects formnorequired
This commit is contained in:
parent
eb7f971d10
commit
62b708438c
@ -13,6 +13,7 @@
|
|||||||
|
|
||||||
.alerts {
|
.alerts {
|
||||||
top: 150px;
|
top: 150px;
|
||||||
|
bottom: auto;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -10,6 +10,12 @@
|
|||||||
if (requireds.length == 0) {
|
if (requireds.length == 0) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
if (typeof button.dataset.formnorequired !== 'undefined' && button.dataset.formnorequired !== null) {
|
||||||
|
button.addEventListener('click', function() {
|
||||||
|
form.submit();
|
||||||
|
});
|
||||||
|
return false;
|
||||||
|
}
|
||||||
updateButtonState();
|
updateButtonState();
|
||||||
|
|
||||||
requireds.forEach(function(el) {
|
requireds.forEach(function(el) {
|
||||||
@ -66,10 +72,10 @@ document.addEventListener('DOMContentLoaded', function() {
|
|||||||
var forms = document.querySelectorAll('form');
|
var forms = document.querySelectorAll('form');
|
||||||
Array.from(forms).forEach(function(form) {
|
Array.from(forms).forEach(function(form) {
|
||||||
// auto reactiveButton submit-buttons with required fields
|
// auto reactiveButton submit-buttons with required fields
|
||||||
var submitBtn = form.querySelector('[type=submit]');
|
var submitBtns = Array.from(form.querySelectorAll('[type=submit]'));
|
||||||
if (submitBtn) {
|
submitBtns.forEach(function(submitBtn) {
|
||||||
window.utils.reactiveButton(form, submitBtn, validateForm);
|
window.utils.reactiveButton(form, submitBtn, validateForm);
|
||||||
}
|
});
|
||||||
|
|
||||||
// auto conditonal fieldsets
|
// auto conditonal fieldsets
|
||||||
var fieldSets = Array.from(form.querySelectorAll('fieldset[data-conditional-id][data-conditional-value]'));
|
var fieldSets = Array.from(form.querySelectorAll('fieldset[data-conditional-id][data-conditional-value]'));
|
||||||
|
|||||||
Reference in New Issue
Block a user