Enable login when pressing enter on fields

This commit is contained in:
Robbie Antenesse 2019-05-24 16:38:08 -06:00
parent b69af6c4f6
commit f0be285b3e
2 changed files with 26 additions and 2 deletions

View File

@ -18,7 +18,7 @@ export function renderLoginForm() {
<input type="password" required id="loginPassword" maxlength="100">
</label>
<section id="loginErrorMessages"></section>
<a id="loginSubmit" class="button">Log In</a><br>
<button id="loginSubmit" class="button">Log In</button><br>
<a id="forgotPasswordButton" class="small button">Forgot Password?</a>
</div>
<div>
@ -42,7 +42,7 @@ export function renderLoginForm() {
<input type="checkbox" id="createNewAllowEmails">
</label>
<section id="createAccountErrorMessages"></section>
<a id="createAccountSubmit" class="button">Create Account</a>
<button id="createAccountSubmit" class="button">Create Account</button>
</div>
</div>
</section>

View File

@ -10,6 +10,30 @@ export function setupLoginModal(modal) {
});
});
[
document.getElementById('loginEmail'),
document.getElementById('loginPassword'),
].forEach(field => {
field.addEventListener('keydown', event => {
if (['Enter', 'Return'].includes(event.key)) {
logIn();
}
});
});
[
document.getElementById('createNewEmail'),
document.getElementById('createNewPassword'),
document.getElementById('createNewConfirm'),
document.getElementById('createNewPublicName'),
].forEach(field => {
field.addEventListener('keydown', event => {
if (['Enter', 'Return'].includes(event.key)) {
createAccount();
}
});
});
document.getElementById('loginSubmit').addEventListener('click', logIn);
document.getElementById('createAccountSubmit').addEventListener('click', createAccount);
}