[pass-reset_script] Refactor. Refactored the script into function
This commit is contained in:
parent
0c9ae88c31
commit
76a28c9995
1 changed files with 4 additions and 2 deletions
|
@ -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>";
|
||||||
}
|
}
|
||||||
});
|
}
|
Loading…
Reference in a new issue