Contact

Stuur ons een mailtje

window.renderFormSuccess = function (form) { const successMessage = document.createElement("div"); successMessage.classList.add("callout", "success"); const paragraph = document.createElement("p"); paragraph.appendChild(document.createTextNode("Formulier is succesvol verstuurd!")); successMessage.appendChild(paragraph); form.insertBefore(successMessage, form.childNodes[0]); }; window.renderErrors = function (errors, form) { for (const key in errors) { if (!errors.hasOwnProperty(key)) { continue; } const messages = errors[key]; const errorsList = document.createElement("ul"); errorsList.classList.add("errors"); for (const message of messages) { const listItem = document.createElement("li"); listItem.appendChild(document.createTextNode(message)); errorsList.appendChild(listItem); } const inputList = form.querySelectorAll("*[name=" + key + "], *[name='" + key + "[]']"); for (const input of inputList) { input.parentElement.classList.add("has-error"); input.parentElement.appendChild(errorsList); } } }; window.renderFormErrors = function (errors, form) { const errorBlock = document.createElement("div"); errorBlock.classList.add("callout", "alert", "form-errors"); errorBlock.appendChild(document.createTextNode("Fout! Gelieve het formulier na te kijken en opnieuw te proberen.")); if (errors.length) { const errorsList = document.createElement("ul"); for (const message of errors) { const listItem = document.createElement("li"); listItem.appendChild(document.createTextNode(message)); errorsList.appendChild(listItem); } errorBlock.appendChild(errorsList); } form.insertBefore(errorBlock, form.childNodes[0]); }; window.removeMessages = (form) => { form.querySelectorAll(".errors").remove(); const fieldsWithErrors = form.querySelectorAll(".has-error"); for (let fieldIndex = 0; fieldIndex < fieldsWithErrors.length; fieldIndex++) { const field=fieldsWithErrors[fieldIndex]; field.classList.remove("has-error"); } form.querySelectorAll(".callout.success").remove(); form.querySelectorAll(".callout.form-errors").remove(); }

Liever chatten?

De chat is doordeweeks te bereiken tussen 8:00 en 17:00.

Open chat