[Pass-reset_script] Moving from the manually coded button to the built-in submit button with preventDefault

This commit is contained in:
eoghan.conlon 2023-07-27 17:55:56 +01:00
parent f592d18ac2
commit 44f635c008

View file

@ -1,13 +1,21 @@
function handleSubmit(form) {
function handleSubmitManual(form) {
const field = "password"
const user = form.uid.value;
const pass = form.oldPW.value;
const newPW = form.newPW.value;
const newPWConfirm = form.newPWConfirm.value;
if (newPW === newPWConfirm){
let obj = { "user": user , "pass": pass , "field": field, "value": newPW }
let obj = { "user": user , "pass": pass , "field": field, "value": newPW };
alert("Form submitted");
} else {
alert("New passwords doesn't match");
}
}
const formEl = document.getElementById("reset");
formEl.addEventListener('submit', () => {
event.preventDefault();
const formData = new FormData(formEl);
const object = Object.fromEntries(formData.entries());
console.log({ object });
});