From 76a28c9995a44ce849a0c999c1d918e51f8c8b36 Mon Sep 17 00:00:00 2001 From: "eoghan.conlon" Date: Thu, 27 Jul 2023 19:08:02 +0100 Subject: [PATCH] [pass-reset_script] Refactor. Refactored the script into function --- src/PassReset/formHandler.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/PassReset/formHandler.js b/src/PassReset/formHandler.js index bae54e5..80809ba 100644 --- a/src/PassReset/formHandler.js +++ b/src/PassReset/formHandler.js @@ -1,5 +1,7 @@ const formEl = document.getElementById("reset"); -formEl.addEventListener('submit', (listener) => { +formEl.addEventListener('submit', (listener) => formHandler(listener)); + +function formHandler(listener){ listener.preventDefault(); const formData = new FormData(formEl); if(formData.get("newPW") === formData.get("newPWConfirm")){ @@ -26,4 +28,4 @@ formEl.addEventListener('submit', (listener) => { } else { document.getElementById('formStatus').innerHTML = "Failure: new passwords don't match"; } -}); \ No newline at end of file +} \ No newline at end of file