function jobFormChangeHandler() { if (jobFormFileElement.files.length === 0 || jobFormLanguageElement.value === "" || jobFormNameElement.value === "") { jobFormSubmitElement.classList.add("disabled"); } else { jobFormSubmitElement.classList.remove("disabled"); } } function jobFormSubmitHandler() { createJob(jobFormFileElement.files[0], jobFormLanguageElement.value, jobFormNameElement.value, jobFormServiceElement.value, user["id"]); } var jobFormElement; var jobFormFileElement; var jobFormLanguageElement; var jobFormNameElement; var jobFormServiceElement; var jobFormSubmitElement; jobFormElement = document.getElementById("job_form"); jobFormFileElement = document.getElementById("job_form_file"); jobFormLanguageElement = document.getElementById("job_form_language"); jobFormNameElement = document.getElementById("job_form_name"); jobFormServiceElement = document.getElementById("job_form_service"); jobFormSubmitElement = document.getElementById("job_form_submit"); jobFormFileElement.addEventListener("change", jobFormChangeHandler); jobFormLanguageElement.addEventListener("change", jobFormChangeHandler); jobFormNameElement.addEventListener("input", jobFormChangeHandler); M.Modal.init( document.getElementById("create_job"), { "onCloseEnd": modal => { jobFormElement.reset(); M.updateTextFields(); } } );