[Pass-reset_script] Form and script now generate the form in format that is required by the backend

This commit is contained in:
eoghan.conlon 2023-07-27 18:19:45 +01:00
parent d1c46e152d
commit b80aa303ac
2 changed files with 15 additions and 7 deletions

View file

@ -17,9 +17,17 @@ formEl.addEventListener('submit', () => {
event.preventDefault();
const formData = new FormData(formEl);
if(formData.get("newPW") === formData.get("newPWConfirm")){
alert("This works");
formData.delete("newPWConfirm");
const newPW = formData.get("newPW");
formData.delete("newPW");
formData.append("field", "password");
formData.append("value", newPW);
const object = Object.fromEntries(formData.entries());
console.log({ object });
//TODO: Change this to changing a div in html
alert("Success");
} else {
alert("Shit");
//TODO: Change this to changing a div in html
alert("Failure")
}
console.log({ object });
});

View file

@ -6,10 +6,10 @@
</head>
<body>
<form id="reset">
<label for="uid">Username</label>
<input type="text" id="uid" name="uid" /> <br />
<label for="oldPw">Old Password</label>
<input type="password" id="oldPw" name="oldPW" /> <br />
<label for="user">Username</label>
<input type="text" id="user" name="user" /> <br />
<label for="pass">Old Password</label>
<input type="password" id="pass" name="pass" /> <br />
<label for="newPW1">New Password</label>
<input type="password" id="newPW1" name="newPW" /> <br />
<label for="newPW2">Confirm</label>