Readd some stuff

This commit is contained in:
Patrick Jentsch 2020-02-18 14:44:31 +01:00
parent 292c24b38f
commit 4f803d0aa6

View File

@ -29,10 +29,23 @@ nopaque.Workarounds.apply = function() {
nopaque.Forms = {};
nopaque.Forms.init = function() {
var abortRequestElement, progressElement, progressModal,
progressModalElement, request;
var abortRequestElement, parentElement, progressElement, progressModal,
progressModalElement, request, submitElement;
for (let form of document.querySelectorAll(".nopaque-job-form")) {
submitElement = form.querySelector('button[type="submit"]');
submitElement.addEventListener("click", function() {
for (let selectElement of form.querySelectorAll('select')) {
if (selectElement.value === "") {
parentElement = selectElement.closest(".input-field");
for (let helperTextElement of parentElement.querySelectorAll(".helper-text")) {
helperTextElement.remove();
}
parentElement.insertAdjacentHTML("beforeend", `<span class="helper-text red-text">Please select an option.</span>`);
}
}
});
request = new XMLHttpRequest();
if (form.dataset.hasOwnProperty("progressModal")) {
progressModalElement = document.getElementById(form.dataset.progressModal);