diff --git a/tasks/calc/formValidation.js b/tasks/calc/formValidation.js new file mode 100644 index 0000000..0d82e69 --- /dev/null +++ b/tasks/calc/formValidation.js @@ -0,0 +1,23 @@ +// Example starter JavaScript for disabling form submissions if there are invalid fields +document.addEventListener("DOMContentLoaded", () => { + "use strict"; + + // Fetch all the forms we want to apply custom Bootstrap validation styles to + const forms = document.querySelectorAll(".needs-validation"); + + // Loop over them and prevent submission + Array.from(forms).forEach((form) => { + form.addEventListener( + "submit", + (event) => { + if (!form.checkValidity()) { + event.preventDefault(); + event.stopPropagation(); + } + + form.classList.add("was-validated"); + }, + false + ); + }); +}); diff --git a/tasks/calc/index.php b/tasks/calc/index.php new file mode 100644 index 0000000..f42dfe9 --- /dev/null +++ b/tasks/calc/index.php @@ -0,0 +1,100 @@ + + + +
+ + + +