2020-02-15 17:34:42 +00:00
|
|
|
document.addEventListener("DOMContentLoaded", () => {
|
|
|
|
let isFormValid = false;
|
|
|
|
let isPassMatch = false;
|
|
|
|
|
|
|
|
const form = document.getElementById('form-register') as HTMLFormElement;
|
|
|
|
const pass = document.getElementById('txt-register-password') as HTMLInputElement;
|
|
|
|
const confirmPass = document.getElementById('txt-register-confirm-password') as HTMLInputElement;
|
|
|
|
const terms = document.getElementById('chk-register-terms') as HTMLInputElement;
|
|
|
|
const submit = document.getElementById('btn-register-submit') as HTMLButtonElement;
|
|
|
|
if (!pass || !confirmPass || !terms) alert('Something Went wrong');
|
|
|
|
|
|
|
|
form.oninput = (ev: Event) => {
|
|
|
|
isPassMatch = (pass.value === confirmPass.value) && !!pass.value.trim().length;
|
|
|
|
validateForm();
|
|
|
|
}
|
|
|
|
|
|
|
|
function validateForm(): void {
|
|
|
|
isFormValid = form.checkValidity() && isPassMatch && terms.checked;
|
|
|
|
submit.disabled = !isFormValid;
|
2020-02-15 18:07:23 +00:00
|
|
|
terms.value = terms.checked ? "on" : "";
|
2020-02-15 17:34:42 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
validateForm();
|
|
|
|
|
|
|
|
});
|