add "re-enter password" field on form

for #14.
This commit is contained in:
Harvey Tindall
2020-11-04 20:46:06 +00:00
parent 34135d645d
commit ba601935b5
7 changed files with 47 additions and 4 deletions
+20
View File
@@ -5,6 +5,8 @@ import { BS4 } from "./modules/bs4.js";
interface formWindow extends Window {
usernameEnabled: boolean;
validationStrings: pwValStrings;
checkPassword(): void;
invalidPassword: string;
}
declare var window: formWindow;
@@ -131,3 +133,21 @@ var code = window.location.href.split('/').pop();
}, true);
return false;
});
window.checkPassword = (): void => {
const entry = document.getElementById('inputPassword') as HTMLInputElement;
if (entry.value != "") {
const reentry = document.getElementById('reInputPassword') as HTMLInputElement;
const identical = (entry.value == reentry.value);
const submitButton = document.getElementById('submitButton') as HTMLButtonElement;
if (identical) {
reentry.setCustomValidity('');
rmAttr(submitButton, "btn-outline-danger");
addAttr(submitButton, "btn-outline-primary");
} else {
reentry.setCustomValidity(window.invalidPassword);
addAttr(submitButton, "btn-outline-danger");
rmAttr(submitButton, "btn-outline-primary");
}
}
}