[Pass-reset_script] Moving from the manually coded button to the built-in submit button with preventDefault
This commit is contained in:
parent
f592d18ac2
commit
44f635c008
1 changed files with 11 additions and 3 deletions
|
@ -1,13 +1,21 @@
|
||||||
function handleSubmit(form) {
|
function handleSubmitManual(form) {
|
||||||
const field = "password"
|
const field = "password"
|
||||||
const user = form.uid.value;
|
const user = form.uid.value;
|
||||||
const pass = form.oldPW.value;
|
const pass = form.oldPW.value;
|
||||||
const newPW = form.newPW.value;
|
const newPW = form.newPW.value;
|
||||||
const newPWConfirm = form.newPWConfirm.value;
|
const newPWConfirm = form.newPWConfirm.value;
|
||||||
if (newPW === newPWConfirm){
|
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");
|
alert("Form submitted");
|
||||||
} else {
|
} else {
|
||||||
alert("New passwords doesn't match");
|
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 });
|
||||||
|
});
|
Loading…
Add table
Reference in a new issue