[pass-reset_script] Refactor. Refactored the script into function

This commit is contained in:
eoghan.conlon 2023-07-27 19:08:02 +01:00
parent 0c9ae88c31
commit 76a28c9995

View file

@ -1,5 +1,7 @@
const formEl = document.getElementById("reset"); const formEl = document.getElementById("reset");
formEl.addEventListener('submit', (listener) => { formEl.addEventListener('submit', (listener) => formHandler(listener));
function formHandler(listener){
listener.preventDefault(); listener.preventDefault();
const formData = new FormData(formEl); const formData = new FormData(formEl);
if(formData.get("newPW") === formData.get("newPWConfirm")){ if(formData.get("newPW") === formData.get("newPWConfirm")){
@ -26,4 +28,4 @@ formEl.addEventListener('submit', (listener) => {
} else { } else {
document.getElementById('formStatus').innerHTML = "<span style='background-color: red; color: white'>Failure: new passwords don't match</span>"; document.getElementById('formStatus').innerHTML = "<span style='background-color: red; color: white'>Failure: new passwords don't match</span>";
} }
}); }